本文整理汇总了C++中stringset::load_factor方法的典型用法代码示例。如果您正苦于以下问题:C++ stringset::load_factor方法的具体用法?C++ stringset::load_factor怎么用?C++ stringset::load_factor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stringset
的用法示例。
在下文中一共展示了stringset::load_factor方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dump_stringset
void dump_stringset (FILE* out) {
size_t max_bucket_size = 0;
for (size_t bucket = 0; bucket < set.bucket_count(); ++bucket) {
bool need_index = true;
size_t curr_size = set.bucket_size (bucket);
if (max_bucket_size < curr_size) max_bucket_size = curr_size;
for (stringset::const_local_iterator itor = set.cbegin (bucket);
itor != set.cend (bucket); ++itor) {
if (need_index) fprintf (out, "stringset[%4lu]: ", bucket);
else fprintf (out, " %4s ", "");
need_index = false;
const string* str = &*itor;
fprintf (out, "%22lu %p->\"%s\"\n",
set.hash_function()(*str),
str, str->c_str());
}
}
fprintf (out, "load_factor = %.3f\n", set.load_factor());
fprintf (out, "bucket_count = %lu\n", set.bucket_count());
fprintf (out, "max_bucket_size = %lu\n", max_bucket_size);
}
示例2: dump_stringset
void dump_stringset (ostream& out) {
size_t max_bucket_size = 0;
for (size_t bucket = 0; bucket < set.bucket_count(); ++bucket) {
bool need_index = true;
size_t curr_size = set.bucket_size (bucket);
if (max_bucket_size < curr_size) max_bucket_size = curr_size;
for (stringset::const_local_iterator itor = set.cbegin (bucket);itor != set.cend (bucket); ++itor) {
if (need_index)
out << "stringset[" << setw(4) << bucket<< "]: ";
else
out << setw(17) << "";
need_index = false;
const string* str = &*itor;
out << setw(22) << set.hash_function()(*str) << ": "<< str << "->\"" << *str << "\"" << endl;
}
}
out << "load_factor = " << fixed << setprecision(3)
<< set.load_factor() << endl;
out << "bucket_count = " << set.bucket_count() << endl;
out << "max_bucket_size = " << max_bucket_size << endl;
}