/** * This method is a convenience for testing. Code should call {@link * MapMakerInternalMap#containsValue} directly. */ @VisibleForTesting boolean containsValue(Object value) { try { if (count != 0) { // read-volatile AtomicReferenceArray<E> table = this.table; int length = table.length(); for (int i = 0; i < length; ++i) { for (E e = table.get(i); e != null; e = e.getNext()) { V entryValue = getLiveValue(e); if (entryValue == null) { continue; } if (map.valueEquivalence().equivalent(value, entryValue)) { return true; } } } } return false; } finally { postReadCleanup(); } }
for (E e = table.get(j); e != null; e = e.getNext()) { V v = segment.getLiveValue(e); if (v != null && valueEquivalence().equivalent(value, v)) { return true;
/** * This method is a convenience for testing. Code should call {@link * MapMakerInternalMap#containsValue} directly. */ @VisibleForTesting boolean containsValue(Object value) { try { if (count != 0) { // read-volatile AtomicReferenceArray<E> table = this.table; int length = table.length(); for (int i = 0; i < length; ++i) { for (E e = table.get(i); e != null; e = e.getNext()) { V entryValue = getLiveValue(e); if (entryValue == null) { continue; } if (map.valueEquivalence().equivalent(value, entryValue)) { return true; } } } } return false; } finally { postReadCleanup(); } }
/** * This method is a convenience for testing. Code should call {@link * MapMakerInternalMap#containsValue} directly. */ @VisibleForTesting boolean containsValue(Object value) { try { if (count != 0) { // read-volatile AtomicReferenceArray<E> table = this.table; int length = table.length(); for (int i = 0; i < length; ++i) { for (E e = table.get(i); e != null; e = e.getNext()) { V entryValue = getLiveValue(e); if (entryValue == null) { continue; } if (map.valueEquivalence().equivalent(value, entryValue)) { return true; } } } } return false; } finally { postReadCleanup(); } }
for (E e = table.get(j); e != null; e = e.getNext()) { V v = segment.getLiveValue(e); if (v != null && valueEquivalence().equivalent(value, v)) { return true;
for (E e = table.get(j); e != null; e = e.getNext()) { V v = segment.getLiveValue(e); if (v != null && valueEquivalence().equivalent(value, v)) { return true;
if (map.valueEquivalence().equivalent(value, entryValue)) { explicitRemoval = true; } else if (isCollected(e)) {
if (map.valueEquivalence().equivalent(oldValue, entryValue)) { ++modCount; setValue(e, newValue);
if (map.valueEquivalence().equivalent(value, entryValue)) { explicitRemoval = true; } else if (isCollected(e)) {
public void testDefaults() { MapMakerInternalMap<Object, Object, ?, ?> map = makeMap(createMapMaker()); assertSame(Strength.STRONG, map.keyStrength()); assertSame(Strength.STRONG, map.valueStrength()); assertSame(map.keyStrength().defaultEquivalence(), map.keyEquivalence); assertSame(map.valueStrength().defaultEquivalence(), map.valueEquivalence()); assertThat(map.entryHelper) .isInstanceOf(MapMakerInternalMap.StrongKeyStrongValueEntry.Helper.class); assertEquals(4, map.concurrencyLevel); // concurrency level assertThat(map.segments).hasLength(4); // initial capacity / concurrency level assertEquals(16 / map.segments.length, map.segments[0].table.length()); }
if (map.valueEquivalence().equivalent(oldValue, entryValue)) { ++modCount; setValue(e, newValue);
private static void checkStrength( MapMakerInternalMap<Object, Object, ?, ?> map, Strength keyStrength, Strength valueStrength) { assertSame(keyStrength, map.keyStrength()); assertSame(valueStrength, map.valueStrength()); assertSame(keyStrength.defaultEquivalence(), map.keyEquivalence); assertSame(valueStrength.defaultEquivalence(), map.valueEquivalence()); }
public void testSetKeyEquivalence() { Equivalence<Object> testEquivalence = new Equivalence<Object>() { @Override protected boolean doEquivalent(Object a, Object b) { return false; } @Override protected int doHash(Object t) { return 0; } }; MapMakerInternalMap<Object, Object, ?, ?> map = makeMap(createMapMaker().keyEquivalence(testEquivalence)); assertSame(testEquivalence, map.keyEquivalence); assertSame(map.valueStrength().defaultEquivalence(), map.valueEquivalence()); }
if (map.valueEquivalence().equivalent(value, entryValue)) { explicitRemoval = true; } else if (isCollected(e)) {
if (map.valueEquivalence().equivalent(oldValue, entryValue)) { ++modCount; setValue(e, newValue);
/** * This method is a convenience for testing. Code should call {@link * MapMakerInternalMap#containsValue} directly. */ @VisibleForTesting boolean containsValue(Object value) { try { if (count != 0) { // read-volatile AtomicReferenceArray<E> table = this.table; int length = table.length(); for (int i = 0; i < length; ++i) { for (E e = table.get(i); e != null; e = e.getNext()) { V entryValue = getLiveValue(e); if (entryValue == null) { continue; } if (map.valueEquivalence().equivalent(value, entryValue)) { return true; } } } } return false; } finally { postReadCleanup(); } }
/** * This method is a convenience for testing. Code should call {@link * MapMakerInternalMap#containsValue} directly. */ @VisibleForTesting boolean containsValue(Object value) { try { if (count != 0) { // read-volatile AtomicReferenceArray<E> table = this.table; int length = table.length(); for (int i = 0; i < length; ++i) { for (E e = table.get(i); e != null; e = e.getNext()) { V entryValue = getLiveValue(e); if (entryValue == null) { continue; } if (map.valueEquivalence().equivalent(value, entryValue)) { return true; } } } } return false; } finally { postReadCleanup(); } }
private static void checkStrength( MapMakerInternalMap<Object, Object, ?, ?> map, Strength keyStrength, Strength valueStrength) { assertSame(keyStrength, map.keyStrength()); assertSame(valueStrength, map.valueStrength()); assertSame(keyStrength.defaultEquivalence(), map.keyEquivalence); assertSame(valueStrength.defaultEquivalence(), map.valueEquivalence()); }
public void testSetKeyEquivalence() { Equivalence<Object> testEquivalence = new Equivalence<Object>() { @Override protected boolean doEquivalent(Object a, Object b) { return false; } @Override protected int doHash(Object t) { return 0; } }; MapMakerInternalMap<Object, Object, ?, ?> map = makeMap(createMapMaker().keyEquivalence(testEquivalence)); assertSame(testEquivalence, map.keyEquivalence); assertSame(map.valueStrength().defaultEquivalence(), map.valueEquivalence()); }
public void testDefaults() { MapMakerInternalMap<Object, Object, ?, ?> map = makeMap(createMapMaker()); assertSame(Strength.STRONG, map.keyStrength()); assertSame(Strength.STRONG, map.valueStrength()); assertSame(map.keyStrength().defaultEquivalence(), map.keyEquivalence); assertSame(map.valueStrength().defaultEquivalence(), map.valueEquivalence()); assertThat(map.entryHelper) .isInstanceOf(MapMakerInternalMap.StrongKeyStrongValueEntry.Helper.class); assertEquals(4, map.concurrencyLevel); // concurrency level assertThat(map.segments).hasLength(4); // initial capacity / concurrency level assertEquals(16 / map.segments.length, map.segments[0].table.length()); }