@Test public void containsValue() { assertTrue(map.containsValue(16)); assertFalse(map.containsValue(4)); }
@Override public boolean containsValue(Object value) { List<Map.Entry<K, V>> sentinelValues = new ArrayList<>(); for (Map.Entry<K, V> e : entrySet()) { if (internalMap.get(e.getKey()) == SENTINEL) sentinelValues.add(e); else if (Objects.equals(e.getValue(), value)) return true; } for (Map.Entry<K, V> e : sentinelValues) { if (Objects.equals(e.getValue(), value)) return true; } return false; }
LazyMap implements Map<K, V> { @Override public boolean containsValue(Object value) { List<Map.Entry<K, V>> sentinelValues = new ArrayList<>(); for (Map.Entry<K, V> e : entrySet()) { if (internalMap.get(e.getKey()) == SENTINEL) sentinelValues.add(e); else if (Objects.equals(e.getValue(), value)) return true; } for (Map.Entry<K, V> e : sentinelValues) { if (Objects.equals(e.getValue(), value)) return true; } return false; } }
LazyMap implements Map<K, V> { @Override public boolean containsValue(Object value) { List<Map.Entry<K, V>> sentinelValues = new ArrayList<>(); for (Map.Entry<K, V> e : entrySet()) { if (internalMap.get(e.getKey()) == SENTINEL) sentinelValues.add(e); else if (Objects.equals(e.getValue(), value)) return true; } for (Map.Entry<K, V> e : sentinelValues) { if (Objects.equals(e.getValue(), value)) return true; } return false; } LazyMap(Function<? super K, ? extends V> compute);  LazyMap(Function<? super K, ? extends V> compute, Supplier<Map<K, V>> mapSupplier);  LazyMap(Function<? super K, ? extends V> compute, Collection<? extends K> initialKeys);  LazyMap(Function<? super K, ? extends V> compute, Collection<? extends K> initialKeys, Supplier<Map<K, V>> mapSupplier); }
LazyMap implements Map<K, V> { @Override public boolean containsValue(Object value) { List<Map.Entry<K, V>> sentinelValues = new ArrayList<>(); for (Map.Entry<K, V> e : entrySet()) { if (internalMap.get(e.getKey()) == SENTINEL) sentinelValues.add(e); else if (Objects.equals(e.getValue(), value)) return true; } for (Map.Entry<K, V> e : sentinelValues) { if (Objects.equals(e.getValue(), value)) return true; } return false; } LazyMap(Function<? super K, ? extends V> compute);  LazyMap(Function<? super K, ? extends V> compute, Supplier<Map<K, V>> mapSupplier);  LazyMap(Function<? super K, ? extends V> compute, Collection<? extends K> initialKeys);  LazyMap(Function<? super K, ? extends V> compute, Collection<? extends K> initialKeys, Supplier<Map<K, V>> mapSupplier); @Override boolean isEmpty(); @Override int size(); @Override V get(Object key); @Override V put(K key, V value); @Override void putAll(Map<? extends K, ? extends V> m); @Override V remove(Object k); @Override Set<K> keySet(); @Override Collection<V> values(); @Override Set<Map.Entry<K, V>> entrySet(); @Override boolean containsKey(Object key); @Override boolean containsValue(Object value); @Override void clear(); @Override int hashCode(); @Override boolean equals(Object o); @Override String toString(); }
LazyMap implements Map<K, V> { @Override public boolean containsValue(Object value) { List<Map.Entry<K, V>> sentinelValues = new ArrayList<>(); for (Map.Entry<K, V> e : entrySet()) { if (internalMap.get(e.getKey()) == SENTINEL) sentinelValues.add(e); else if (Objects.equals(e.getValue(), value)) return true; } for (Map.Entry<K, V> e : sentinelValues) { if (Objects.equals(e.getValue(), value)) return true; } return false; } LazyMap(Function<? super K, ? extends V> compute);  LazyMap(Function<? super K, ? extends V> compute, Supplier<Map<K, V>> mapSupplier);  LazyMap(Function<? super K, ? extends V> compute, Collection<? extends K> initialKeys);  LazyMap(Function<? super K, ? extends V> compute, Collection<? extends K> initialKeys, Supplier<Map<K, V>> mapSupplier); @Override boolean isEmpty(); @Override int size(); @Override V get(Object key); @Override V put(K key, V value); @Override void putAll(Map<? extends K, ? extends V> m); @Override V remove(Object k); @Override Set<K> keySet(); @Override Collection<V> values(); @Override Set<Map.Entry<K, V>> entrySet(); @Override boolean containsKey(Object key); @Override boolean containsValue(Object value); @Override void clear(); @Override int hashCode(); @Override boolean equals(Object o); @Override String toString();  }