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

Class TreeMap

lib/java/util/TreeMap.java:33–2410  ·  view source on GitHub ↗

TreeMap is an implementation of SortedMap. All optional operations (adding and removing) are supported. The values can be any objects. The keys can be any objects which are comparable to each other either using their natural order or a specified Comparator. @since 1.2

Source from the content-addressed store, hash-verified

31 * @since 1.2
32 */
33public class TreeMap <K, V> extends AbstractMap<K, V> implements SortedMap<K, V>,
34 Cloneable, Serializable {
35 private static final long serialVersionUID = 919286545866124006L;
36
37 transient int size;
38
39 private Comparator<? super K> comparator;
40
41 transient int modCount;
42
43 transient Set<Map.Entry<K, V>> entrySet;
44
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];

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected