Example #1
0
void HatDescDeallocate()
{
    for (unsigned i = 0; i < cache_g.bucket_count(); i++) {
        for (auto local_it = cache_g.begin(i); local_it != cache_g.end(i); ++local_it) {
            local_it->second.deallocate();
        }
    }
}
Example #2
0
 Key sample_key(const std::unordered_map<Key, T>& map, Generator& rng) {
   assert(!map.empty());
   std::uniform_int_distribution<std::size_t> ub(0, map.bucket_count() - 1);
   while (true) {
     std::size_t bucket = ub(rng);
     std::size_t bsize = map.bucket_size(bucket);
     if (bsize > 0) {
       std::uniform_int_distribution<std::size_t> ui(0, bsize - 1);
       return std::next(map.begin(bucket), ui(rng))->first;
     }
   }
 }