MCPcopy Index your code
hub / github.com/davidgiven/luje / AbstractMap

Class AbstractMap

lib/java/util/AbstractMap.java:27–456  ·  view source on GitHub ↗

This class is an abstract implementation of the Map interface. This implementation does not support adding. A subclass must implement the abstract method entrySet(). @since 1.2

Source from the content-addressed store, hash-verified

25 * @since 1.2
26 */
27public abstract class AbstractMap<K, V> implements Map<K, V> {
28
29 // Lazily initialized key set.
30 Set<K> keySet;
31
32 Collection<V> valuesCollection;
33
34 /**
35 * Constructs a new instance of this {@code AbstractMap}.
36 */
37 protected AbstractMap() {
38 super();
39 }
40
41 /**
42 * Removes all elements from this map, leaving it empty.
43 *
44 * @throws UnsupportedOperationException
45 * if removing from this map is not supported.
46 * @see #isEmpty()
47 * @see #size()
48 */
49 public void clear() {
50 entrySet().clear();
51 }
52
53 /**
54 * Returns whether this map contains the specified key.
55 *
56 * @param key
57 * the key to search for.
58 * @return {@code true} if this map contains the specified key,
59 * {@code false} otherwise.
60 */
61 public boolean containsKey(Object key) {
62 Iterator<Map.Entry<K, V>> it = entrySet().iterator();
63 if (key != null) {
64 while (it.hasNext()) {
65 if (key.equals(it.next().getKey())) {
66 return true;
67 }
68 }
69 } else {
70 while (it.hasNext()) {
71 if (it.next().getKey() == null) {
72 return true;
73 }
74 }
75 }
76 return false;
77 }
78
79 /**
80 * Returns whether this map contains the specified value.
81 *
82 * @param value
83 * the value to search for.
84 * @return {@code true} if this map contains the specified value,

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected