< prev index next >

src/hotspot/share/classfile/compactHashtable.hpp

Print this page

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

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