MCPcopy Index your code
hub / github.com/CyanogenMod/android_libcore / AbstractMap

Class AbstractMap

luni/src/main/java/java/util/AbstractMap.java:35–506  ·  view source on GitHub ↗

A base class for Map implementations. Subclasses that permit new mappings to be added must override #put. The default implementations of many methods are inefficient for large maps. For example in the default implementation, each call to #get performs a linear iterati

Source from the content-addressed store, hash-verified

33 * @since 1.2
34 */
35public abstract class AbstractMap<K, V> implements Map<K, V> {
36 // Lazily-initialized key set (for implementing {@link #keySet}).
37 Set<K> keySet;
38
39 // Lazily-initialized values collection (for implementing {@link #values}).
40 Collection<V> valuesCollection;
41
42 /**
43 * An immutable key-value mapping. Despite the name, this class is non-final
44 * and its subclasses may be mutable.
45 *
46 * @since 1.6
47 */
48 public static class SimpleImmutableEntry<K, V>
49 implements Map.Entry<K, V>, Serializable {
50 private static final long serialVersionUID = 7138329143949025153L;
51
52 private final K key;
53 private final V value;
54
55 public SimpleImmutableEntry(K theKey, V theValue) {
56 key = theKey;
57 value = theValue;
58 }
59
60 /**
61 * Constructs an instance with the key and value of {@code copyFrom}.
62 */
63 public SimpleImmutableEntry(Map.Entry<? extends K, ? extends V> copyFrom) {
64 key = copyFrom.getKey();
65 value = copyFrom.getValue();
66 }
67
68 public K getKey() {
69 return key;
70 }
71
72 public V getValue() {
73 return value;
74 }
75
76 /**
77 * This base implementation throws {@code UnsupportedOperationException}
78 * always.
79 */
80 public V setValue(V object) {
81 throw new UnsupportedOperationException();
82 }
83
84 @Override public boolean equals(Object object) {
85 if (this == object) {
86 return true;
87 }
88 if (object instanceof Map.Entry) {
89 Map.Entry<?, ?> entry = (Map.Entry<?, ?>) object;
90 return (key == null ? entry.getKey() == null : key.equals(entry
91 .getKey()))
92 && (value == null ? entry.getValue() == null : value

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected