コード例 #1
0
ファイル: Segment.java プロジェクト: OpenHFT/SmoothieMap
 final boolean containsValue(SmoothieMap<K, V> map, V value) {
   V v;
   for (long a,
           tail,
           allocations = (a = ~bitSet) << (tail = Long.numberOfLeadingZeros(a)),
           allocIndex = 64 - tail;
       allocations != 0;
       allocations <<= 1, allocIndex--) {
     if (allocations < 0) {
       if (((v = readValue(allocIndex)) == value
           || (value != null && map.valuesEqual(value, v)))) {
         return true;
       }
     }
   }
   return false;
 }
コード例 #2
0
ファイル: Segment.java プロジェクト: OpenHFT/SmoothieMap
 /**
  * @param matchValue {@code true} if should compare the mapped value to the given {@code value}
  *     before remove
  */
 final long remove(
     SmoothieMap<K, V> map, long hash, Object key, Object value, boolean matchValue) {
   long slotIndex, slot, allocIndex, storedHash = storedHash(hash);
   K k;
   V v;
   for (slotIndex = slotIndex(hash);
       (slot = readSlot(slotIndex)) != 0;
       slotIndex = nextSlotIndex(slotIndex)) {
     if (hash(slot) == storedHash
         && ((k = readKey((allocIndex = allocIndex(slot)))) == key
             || (key != null && map.keysEqual(key, k)))) {
       if (!matchValue
           || (v = readValue(allocIndex)) == value
           || (value != null && map.valuesEqual(value, v))) {
         removeButAlloc(map, slotIndex);
         return allocIndex;
       } else {
         return 0;
       }
     }
   }
   return 0;
 }