265 // This is a regular bucket, which has more than one
266 // entries. Each entry is a pair of entry (hash, offset).
267 // Seek until the end of the bucket.
268 u4* entry_max = _entries + BUCKET_OFFSET(_buckets[index + 1]);
269 while (entry < entry_max) {
270 unsigned int h = (unsigned int)(entry[0]);
271 if (h == hash) {
272 V value = decode(entry[1]);
273 if (EQUALS(value, key, len)) {
274 return value;
275 }
276 }
277 entry += 2;
278 }
279 }
280 }
281 return nullptr;
282 }
283
284 template <class ITER>
285 inline void iterate(ITER* iter) const {
286 for (u4 i = 0; i < _bucket_count; i++) {
287 u4 bucket_info = _buckets[i];
288 u4 bucket_offset = BUCKET_OFFSET(bucket_info);
289 int bucket_type = BUCKET_TYPE(bucket_info);
290 u4* entry = _entries + bucket_offset;
291
292 if (bucket_type == VALUE_ONLY_BUCKET_TYPE) {
293 iter->do_value(decode(entry[0]));
294 } else {
295 u4*entry_max = _entries + BUCKET_OFFSET(_buckets[i + 1]);
296 while (entry < entry_max) {
297 iter->do_value(decode(entry[1]));
298 entry += 2;
299 }
300 }
301 }
302 }
303
304 void print_table_statistics(outputStream* st, const char* name) {
305 st->print_cr("%s statistics:", name);
306 int total_entries = 0;
307 int max_bucket = 0;
308 for (u4 i = 0; i < _bucket_count; i++) {
309 u4 bucket_info = _buckets[i];
310 int bucket_type = BUCKET_TYPE(bucket_info);
311 int bucket_size;
312
313 if (bucket_type == VALUE_ONLY_BUCKET_TYPE) {
314 bucket_size = 1;
315 } else {
316 bucket_size = (BUCKET_OFFSET(_buckets[i + 1]) - BUCKET_OFFSET(bucket_info)) / 2;
317 }
|
265 // This is a regular bucket, which has more than one
266 // entries. Each entry is a pair of entry (hash, offset).
267 // Seek until the end of the bucket.
268 u4* entry_max = _entries + BUCKET_OFFSET(_buckets[index + 1]);
269 while (entry < entry_max) {
270 unsigned int h = (unsigned int)(entry[0]);
271 if (h == hash) {
272 V value = decode(entry[1]);
273 if (EQUALS(value, key, len)) {
274 return value;
275 }
276 }
277 entry += 2;
278 }
279 }
280 }
281 return nullptr;
282 }
283
284 template <class ITER>
285 inline void iterate(ITER* iter) const { iterate([&](V v) { iter->do_value(v); }); }
286
287 template<typename Function>
288 inline void iterate(const Function& function) const { // lambda enabled API
289 iterate(const_cast<Function&>(function));
290 }
291
292 template<typename Function>
293 inline void iterate(Function& function) const { // lambda enabled API
294 for (u4 i = 0; i < _bucket_count; i++) {
295 u4 bucket_info = _buckets[i];
296 u4 bucket_offset = BUCKET_OFFSET(bucket_info);
297 int bucket_type = BUCKET_TYPE(bucket_info);
298 u4* entry = _entries + bucket_offset;
299
300 if (bucket_type == VALUE_ONLY_BUCKET_TYPE) {
301 function(decode(entry[0]));
302 } else {
303 u4* entry_max = _entries + BUCKET_OFFSET(_buckets[i + 1]);
304 while (entry < entry_max) {
305 function(decode(entry[1]));
306 entry += 2;
307 }
308 }
309 }
310 }
311
312 void print_table_statistics(outputStream* st, const char* name) {
313 st->print_cr("%s statistics:", name);
314 int total_entries = 0;
315 int max_bucket = 0;
316 for (u4 i = 0; i < _bucket_count; i++) {
317 u4 bucket_info = _buckets[i];
318 int bucket_type = BUCKET_TYPE(bucket_info);
319 int bucket_size;
320
321 if (bucket_type == VALUE_ONLY_BUCKET_TYPE) {
322 bucket_size = 1;
323 } else {
324 bucket_size = (BUCKET_OFFSET(_buckets[i + 1]) - BUCKET_OFFSET(bucket_info)) / 2;
325 }
|