285 template <class ITER>
286 inline void iterate(ITER* iter) const {
287 for (u4 i = 0; i < _bucket_count; i++) {
288 u4 bucket_info = _buckets[i];
289 u4 bucket_offset = BUCKET_OFFSET(bucket_info);
290 int bucket_type = BUCKET_TYPE(bucket_info);
291 u4* entry = _entries + bucket_offset;
292
293 if (bucket_type == VALUE_ONLY_BUCKET_TYPE) {
294 iter->do_value(decode(entry[0]));
295 } else {
296 u4*entry_max = _entries + BUCKET_OFFSET(_buckets[i + 1]);
297 while (entry < entry_max) {
298 iter->do_value(decode(entry[1]));
299 entry += 2;
300 }
301 }
302 }
303 }
304
305 void print_table_statistics(outputStream* st, const char* name) {
306 st->print_cr("%s statistics:", name);
307 int total_entries = 0;
308 int max_bucket = 0;
309 for (u4 i = 0; i < _bucket_count; i++) {
310 u4 bucket_info = _buckets[i];
311 int bucket_type = BUCKET_TYPE(bucket_info);
312 int bucket_size;
313
314 if (bucket_type == VALUE_ONLY_BUCKET_TYPE) {
315 bucket_size = 1;
316 } else {
317 bucket_size = (BUCKET_OFFSET(_buckets[i + 1]) - BUCKET_OFFSET(bucket_info)) / 2;
318 }
319 total_entries += bucket_size;
320 if (max_bucket < bucket_size) {
321 max_bucket = bucket_size;
322 }
323 }
324 st->print_cr("Number of buckets : %9d", _bucket_count);
|
285 template <class ITER>
286 inline void iterate(ITER* iter) const {
287 for (u4 i = 0; i < _bucket_count; i++) {
288 u4 bucket_info = _buckets[i];
289 u4 bucket_offset = BUCKET_OFFSET(bucket_info);
290 int bucket_type = BUCKET_TYPE(bucket_info);
291 u4* entry = _entries + bucket_offset;
292
293 if (bucket_type == VALUE_ONLY_BUCKET_TYPE) {
294 iter->do_value(decode(entry[0]));
295 } else {
296 u4*entry_max = _entries + BUCKET_OFFSET(_buckets[i + 1]);
297 while (entry < entry_max) {
298 iter->do_value(decode(entry[1]));
299 entry += 2;
300 }
301 }
302 }
303 }
304
305 template<typename Function>
306 inline void iterate(Function function) const { // lambda enabled API
307 for (u4 i = 0; i < _bucket_count; i++) {
308 u4 bucket_info = _buckets[i];
309 u4 bucket_offset = BUCKET_OFFSET(bucket_info);
310 int bucket_type = BUCKET_TYPE(bucket_info);
311 u4* entry = _entries + bucket_offset;
312
313 if (bucket_type == VALUE_ONLY_BUCKET_TYPE) {
314 function(decode(entry[0]));
315 } else {
316 u4* entry_max = _entries + BUCKET_OFFSET(_buckets[i + 1]);
317 while (entry < entry_max) {
318 function(decode(entry[1]));
319 entry += 2;
320 }
321 }
322 }
323 }
324
325 void print_table_statistics(outputStream* st, const char* name) {
326 st->print_cr("%s statistics:", name);
327 int total_entries = 0;
328 int max_bucket = 0;
329 for (u4 i = 0; i < _bucket_count; i++) {
330 u4 bucket_info = _buckets[i];
331 int bucket_type = BUCKET_TYPE(bucket_info);
332 int bucket_size;
333
334 if (bucket_type == VALUE_ONLY_BUCKET_TYPE) {
335 bucket_size = 1;
336 } else {
337 bucket_size = (BUCKET_OFFSET(_buckets[i + 1]) - BUCKET_OFFSET(bucket_info)) / 2;
338 }
339 total_entries += bucket_size;
340 if (max_bucket < bucket_size) {
341 max_bucket = bucket_size;
342 }
343 }
344 st->print_cr("Number of buckets : %9d", _bucket_count);
|