hash_map::max_load_factor (STL/CLR)
버킷 당 최대 요소를 가져오거나 설정 합니다.
float max_load_factor();
void max_load_factor(float new_factor);
매개 변수
- new_factor
새 최대 로드 요소를 저장 합니다.
설명
첫 번째 멤버 함수는 현재 저장 된 최대 부하 비율을 반환합니다.평균 통 최대 크기를 확인 하려면 사용 합니다.
저장소 최대 부하 계수와 두 번째 멤버 함수를 대체 합니다. new_factor.자동 해싱하여는 후속 삽입 될 때까지 발생합니다.
예제
// cliext_hash_map_max_load_factor.cpp
// compile with: /clr
#include <cliext/hash_map>
typedef cliext::hash_map<wchar_t, int> Myhash_map;
int main()
{
Myhash_map c1 = gcnew Myhash_map;
c1.insert(Myhash_map::make_value(L'a', 1));
c1.insert(Myhash_map::make_value(L'b', 2));
c1.insert(Myhash_map::make_value(L'c', 3));
// display contents " [a 1] [b 2] [c 3]"
for each (Myhash_map::value_type elem in c1)
System::Console::Write(" [{0} {1}]", elem->first, elem->second);
System::Console::WriteLine();
// inspect current parameters
System::Console::WriteLine("bucket_count() = {0}", c1.bucket_count());
System::Console::WriteLine("load_factor() = {0}", c1.load_factor());
System::Console::WriteLine("max_load_factor() = {0}",
c1.max_load_factor());
System::Console::WriteLine();
// change max_load_factor and redisplay
c1.max_load_factor(0.25f);
System::Console::WriteLine("bucket_count() = {0}", c1.bucket_count());
System::Console::WriteLine("load_factor() = {0}", c1.load_factor());
System::Console::WriteLine("max_load_factor() = {0}",
c1.max_load_factor());
System::Console::WriteLine();
// rehash and redisplay
c1.rehash(100);
System::Console::WriteLine("bucket_count() = {0}", c1.bucket_count());
System::Console::WriteLine("load_factor() = {0}", c1.load_factor());
System::Console::WriteLine("max_load_factor() = {0}",
c1.max_load_factor());
return (0);
}
요구 사항
헤더: < cliext/hash_map >
네임 스페이스: cliext
참고 항목
참조
hash_map::bucket_count (STL/CLR)