MCPcopy Create free account
hub / github.com/davidgiven/luje / MapEntry

Class MapEntry

lib/java/util/TreeMap.java:47–121  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

45 transient Node<K, V> root;
46
47class MapEntry implements Map.Entry<K, V>, Cloneable {
48
49 final int offset;
50 final Node<K, V> node;
51 final K key;
52
53 MapEntry(Node<K, V> node, int offset) {
54 this.node = node;
55 this.offset = offset;
56 key = node.keys[offset];
57 }
58
59 @Override
60 public Object clone() {
61 try {
62 return super.clone();
63 } catch (CloneNotSupportedException e) {
64 return null;
65 }
66 }
67
68 @Override
69 public boolean equals(Object object) {
70 if (this == object) {
71 return true;
72 }
73 if (object instanceof Map.Entry) {
74 Map.Entry<?, ?> entry = (Map.Entry<?, ?>) object;
75 V value = getValue();
76 return (key == null ? entry.getKey() == null : key.equals(entry
77 .getKey()))
78 && (value == null ? entry.getValue() == null : value
79 .equals(entry.getValue()));
80 }
81 return false;
82 }
83
84 public K getKey() {
85 return key;
86 }
87
88 public V getValue() {
89 if (node.keys[offset] == key) {
90 return node.values[offset];
91 }
92 if (containsKey(key)) {
93 return get(key);
94 }
95 throw new IllegalStateException();
96 }
97
98 @Override
99 public int hashCode() {
100 V value = getValue();
101 return (key == null ? 0 : key.hashCode())
102 ^ (value == null ? 0 : value.hashCode());
103 }
104

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected