Esempio n. 1
0
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);
}
Esempio n. 2
0
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;
}
const string* intern_stringset (const char* string) {
   pair<stringset::const_iterator,bool> handle = set.insert (string);
   return &*handle.first;
}