< prev index next >

src/hotspot/share/classfile/compactHashtable.hpp

Print this page

285         u4* entry_max = _entries + BUCKET_OFFSET(_buckets[index + 1]);
286         while (entry < entry_max) {
287           unsigned int h = (unsigned int)(entry[0]);
288           if (h == hash) {
289             V value = decode(entry[1]);
290             if (EQUALS(value, key, len)) {
291               return value;
292             }
293           }
294           entry += 2;
295         }
296       }
297     }
298     return nullptr;
299   }
300 
301   // Iterate through the values in the table, stopping when do_value() returns false.
302   template <class ITER>
303   inline void iterate(ITER* iter) const { iterate([&](V v) { iter->do_value(v); }); }
304 
305   template<typename Function>
306   inline void iterate(const Function& function) const { // lambda enabled API
307     iterate(const_cast<Function&>(function));
308   }
309 
310   // Iterate through the values in the table, stopping when the lambda returns false.
311   template<typename Function>
312   inline void iterate(Function& function) const { // lambda enabled API
313     for (u4 i = 0; i < _bucket_count; i++) {
314       u4 bucket_info = _buckets[i];
315       u4 bucket_offset = BUCKET_OFFSET(bucket_info);
316       int bucket_type = BUCKET_TYPE(bucket_info);
317       u4* entry = _entries + bucket_offset;
318 
319       if (bucket_type == VALUE_ONLY_BUCKET_TYPE) {
320         if (!function(decode(entry[0]))) {
321           return;
322         }
323       } else {
324         u4* entry_max = _entries + BUCKET_OFFSET(_buckets[i + 1]);
325         while (entry < entry_max) {
326           if (!function(decode(entry[1]))) {
327             return;
328           }
329           entry += 2;
330         }
331       }
332     }

285         u4* entry_max = _entries + BUCKET_OFFSET(_buckets[index + 1]);
286         while (entry < entry_max) {
287           unsigned int h = (unsigned int)(entry[0]);
288           if (h == hash) {
289             V value = decode(entry[1]);
290             if (EQUALS(value, key, len)) {
291               return value;
292             }
293           }
294           entry += 2;
295         }
296       }
297     }
298     return nullptr;
299   }
300 
301   // Iterate through the values in the table, stopping when do_value() returns false.
302   template <class ITER>
303   inline void iterate(ITER* iter) const { iterate([&](V v) { iter->do_value(v); }); }
304 





305   // Iterate through the values in the table, stopping when the lambda returns false.
306   template<typename Function>
307   inline void iterate(Function function) const { // lambda enabled API
308     for (u4 i = 0; i < _bucket_count; i++) {
309       u4 bucket_info = _buckets[i];
310       u4 bucket_offset = BUCKET_OFFSET(bucket_info);
311       int bucket_type = BUCKET_TYPE(bucket_info);
312       u4* entry = _entries + bucket_offset;
313 
314       if (bucket_type == VALUE_ONLY_BUCKET_TYPE) {
315         if (!function(decode(entry[0]))) {
316           return;
317         }
318       } else {
319         u4* entry_max = _entries + BUCKET_OFFSET(_buckets[i + 1]);
320         while (entry < entry_max) {
321           if (!function(decode(entry[1]))) {
322             return;
323           }
324           entry += 2;
325         }
326       }
327     }
< prev index next >