hash_set::max_load_factor (STL/CLR)
取得或設定每一桶的最大的項目。
float max_load_factor();
void max_load_factor(float new_factor);
參數
- new_factor
新的最大值載入儲存的因數。
備註
第一個成員函式會傳回目前預存的最大負載因數。 您可以用它來判斷最大值的平均區大小。
第二個成員函式會取代存放區最大的載入因數與new_factor。 沒有自動重新發生直到後續的插入。
範例
// cliext_hash_set_max_load_factor.cpp
// compile with: /clr
#include <cliext/hash_set>
typedef cliext::hash_set<wchar_t> Myhash_set;
int main()
{
Myhash_set c1;
c1.insert(L'a');
c1.insert(L'b');
c1.insert(L'c');
// display initial contents " a b c"
for each (wchar_t elem in c1)
System::Console::Write(" {0}", elem);
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_set >
Namespace: cliext
請參閱
參考
hash_set::bucket_count (STL/CLR)