TreeMap, this class uses insertion order for
iteration order. Comparison order is only used as an optimization for efficient insertion and
removal.
This implementation was derived from Android 4.1's TreeMap class.
| Modifier and Type | Class and Description |
|---|---|
| pack-priv class | |
| pack-priv class | |
| private abstract class | |
| pack-priv static class |
| Modifier and Type | Field and Description |
|---|---|
| private final boolean | |
| private final Comparator | |
| private LinkedTreeMap | |
| pack-priv final LinkedTreeMap. | |
| private LinkedTreeMap | |
| pack-priv int | |
| private static final Comparator | |
| pack-priv LinkedTreeMap. | |
| pack-priv int |
| Access | Constructor and Description |
|---|---|
| public | LinkedTreeMap()
Create a natural order, empty tree map whose keys must be mutually comparable and non-null, and
whose values can be |
| public | LinkedTreeMap(boolean
whether allowNullValues)null is allowed as entry valueCreate a natural order, empty tree map whose keys must be mutually comparable and non-null. |
| public | LinkedTreeMap(Comparator<? super K>
the comparator to order elements with, or comparator, boolean null to use the natural
ordering.whether allowNullValues)null is allowed as entry valueCreate a tree map ordered by |
| Modifier and Type | Method and Description |
|---|---|
| public void | clear()
Overrides java. Implements java. Removes all of the mappings from this map (optional operation). |
| public boolean | containsKey(Object key)
Overrides java. Implements java. Returns |
| public Set | entrySet()
Implements abstract java. Implements java. Returns a |
| private static boolean | |
| pack-priv LinkedTreeMap. | find(K key, boolean create)
Returns the node at or adjacent to the given key, creating it if requested. |
| pack-priv LinkedTreeMap. | findByEntry(Map.
Returns this map's entry that has the same key and value as |
| pack-priv LinkedTreeMap. | |
| public V | get(Object key)
Overrides java. Implements java. Returns the value to which the specified key is mapped,
or |
| public Set | keySet()
Overrides java. Implements java. Returns a |
| public V | put(K key, V value)
Overrides java. Implements java. Associates the specified value with the specified key in this map (optional operation). |
| private void | |
| private void | rebalance(LinkedTreeMap.
true if the node was unbalanced by an insert; false if it was by a removal. insert)Rebalances the tree by making any AVL rotations necessary between the newly-unbalanced node and the tree's root. |
| public V | remove(Object key)
Overrides java. Implements java. Removes the mapping for a key from this map if it is present (optional operation). |
| pack-priv void | removeInternal(LinkedTreeMap.
true to also unlink this node from the iteration linked list. unlink)Removes |
| pack-priv LinkedTreeMap. | |
| private void | |
| private void | rotateLeft(LinkedTreeMap.
Rotates the subtree so that its root's right child is the new root. |
| private void | rotateRight(LinkedTreeMap.
Rotates the subtree so that its root's left child is the new root. |
| public int | size()
Overrides java. Implements java. Returns the number of key-value mappings in this map. |
| private Object | writeReplace()
If somebody is unlucky enough to have to serialize one of these, serialize it as a LinkedHashMap so that they won't need Gson on the other side to deserialize it. |
| allowNullValues | back to summary |
|---|---|
| private final boolean allowNullValues | |
| comparator | back to summary |
|---|---|
| private final Comparator<? super K> comparator | |
| entrySet | back to summary |
|---|---|
| private LinkedTreeMap<K, V>. | |
| header | back to summary |
|---|---|
| pack-priv final LinkedTreeMap. | |
| keySet | back to summary |
|---|---|
| private LinkedTreeMap<K, V>. Hides java. | |
| modCount | back to summary |
|---|---|
| pack-priv int modCount | |
| NATURAL_ORDER | back to summary |
|---|---|
private static final Comparator<Comparable<T>> NATURAL_ORDER
| |
| root | back to summary |
|---|---|
| pack-priv LinkedTreeMap. | |
| size | back to summary |
|---|---|
| pack-priv int size | |
| LinkedTreeMap | back to summary |
|---|---|
| public LinkedTreeMap() Create a natural order, empty tree map whose keys must be mutually comparable and non-null, and
whose values can be
| |
| LinkedTreeMap | back to summary |
|---|---|
| public LinkedTreeMap(boolean allowNullValues) Create a natural order, empty tree map whose keys must be mutually comparable and non-null.
| |
| LinkedTreeMap | back to summary |
|---|---|
| public LinkedTreeMap(Comparator<? super K> comparator, boolean allowNullValues) Create a tree map ordered by
| |
| clear | back to summary |
|---|---|
| public void clear() Overrides java. Implements java. Doc from java. Removes all of the mappings from this map (optional operation). The map will be empty after this call returns.
| |
| containsKey | back to summary |
|---|---|
| public boolean containsKey(Object key) Overrides java. Implements java. Doc from java. Returns
| |
| entrySet | back to summary |
|---|---|
| public Set Implements abstract java. Implements java. Doc from java. Returns a
| |
| equal | back to summary |
|---|---|
| private static boolean equal(Object a, Object b) | |
| find | back to summary |
|---|---|
| pack-priv LinkedTreeMap. Returns the node at or adjacent to the given key, creating it if requested.
| |
| findByEntry | back to summary |
|---|---|
| pack-priv LinkedTreeMap. Returns this map's entry that has the same key and value as This method uses the comparator for key equality rather than | |
| findByObject | back to summary |
|---|---|
pack-priv LinkedTreeMap.
| |
| get | back to summary |
|---|---|
| public V get(Object key) Overrides java. Implements java. Doc from java. Returns the value to which the specified key is mapped,
or More formally, if this map contains a mapping from a key
If this map permits null values, then a return value of
| |
| keySet | back to summary |
|---|---|
| public Set Overrides java. Implements java. Doc from java. Returns a
| |
| put | back to summary |
|---|---|
| public V put(K key, V value) Overrides java. Implements java. Doc from java. Associates the specified value with the specified key in this map
(optional operation). If the map previously contained a mapping for
the key, the old value is replaced by the specified value. (A map
| |
| readObject | back to summary |
|---|---|
| private void readObject(ObjectInputStream in) throws IOException | |
| rebalance | back to summary |
|---|---|
| private void rebalance(LinkedTreeMap. Rebalances the tree by making any AVL rotations necessary between the newly-unbalanced node and the tree's root.
| |
| remove | back to summary |
|---|---|
| public V remove(Object key) Overrides java. Implements java. Doc from java. Removes the mapping for a key from this map if it is present
(optional operation). More formally, if this map contains a mapping
from key Returns the value to which this map previously associated the key,
or If this map permits null values, then a return value of
The map will not contain a mapping for the specified key once the call returns.
| |
| removeInternal | back to summary |
|---|---|
| pack-priv void removeInternal(LinkedTreeMap. Removes
| |
| removeInternalByKey | back to summary |
|---|---|
| pack-priv LinkedTreeMap. | |
| replaceInParent | back to summary |
|---|---|
private void replaceInParent(LinkedTreeMap.
| |
| rotateLeft | back to summary |
|---|---|
| private void rotateLeft(LinkedTreeMap. Rotates the subtree so that its root's right child is the new root. | |
| rotateRight | back to summary |
|---|---|
| private void rotateRight(LinkedTreeMap. Rotates the subtree so that its root's left child is the new root. | |
| size | back to summary |
|---|---|
| public int size() Overrides java. Implements java. Doc from java. Returns the number of key-value mappings in this map. If the
map contains more than
| |
| writeReplace | back to summary |
|---|---|
| private Object writeReplace() throws ObjectStreamException If somebody is unlucky enough to have to serialize one of these, serialize it as a LinkedHashMap so that they won't need Gson on the other side to deserialize it. Using serialization defeats our DoS defence, so most apps shouldn't use it. | |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public void | clear()
Overrides java. Implements java. Removes all of the elements from this set (optional operation). |
| public boolean | contains(Object o)
Overrides java. Implements java. Returns |
| public Iterator | iterator()
Implements abstract java. Implements java. Returns an iterator over the elements in this set. |
| public boolean | remove(Object o)
Overrides java. Implements java. Removes the specified element from this set if it is present (optional operation). |
| public int | size()
Implements abstract java. Implements java. Returns the number of elements in this set (its cardinality). |
| EntrySet | back to summary |
|---|---|
| pack-priv EntrySet() | |
| clear | back to summary |
|---|---|
| public void clear() Overrides java. Implements java. Doc from java. Removes all of the elements from this set (optional operation). The set will be empty after this call returns.
| |
| contains | back to summary |
|---|---|
| public boolean contains(Object o) Overrides java. Implements java. Doc from java. Returns
| |
| iterator | back to summary |
|---|---|
| public Iterator Implements abstract java. Implements java. Doc from java. Returns an iterator over the elements in this set. The elements are returned in no particular order (unless this set is an instance of some class that provides a guarantee).
| |
| remove | back to summary |
|---|---|
| public boolean remove(Object o) Overrides java. Implements java. Doc from java. Removes the specified element from this set if it is present
(optional operation). More formally, removes an element
| |
| size | back to summary |
|---|---|
| public int size() Implements abstract java. Implements java. Doc from java. Returns the number of elements in this set (its cardinality). If this
set contains more than
| |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public void | clear()
Overrides java. Implements java. Removes all of the elements from this set (optional operation). |
| public boolean | contains(Object o)
Overrides java. Implements java. Returns |
| public Iterator | iterator()
Implements abstract java. Implements java. Returns an iterator over the elements in this set. |
| public boolean | remove(Object key)
Overrides java. Implements java. Removes the specified element from this set if it is present (optional operation). |
| public int | size()
Implements abstract java. Implements java. Returns the number of elements in this set (its cardinality). |
| KeySet | back to summary |
|---|---|
| pack-priv KeySet() | |
| clear | back to summary |
|---|---|
| public void clear() Overrides java. Implements java. Doc from java. Removes all of the elements from this set (optional operation). The set will be empty after this call returns.
| |
| contains | back to summary |
|---|---|
| public boolean contains(Object o) Overrides java. Implements java. Doc from java. Returns
| |
| iterator | back to summary |
|---|---|
| public Iterator Implements abstract java. Implements java. Doc from java. Returns an iterator over the elements in this set. The elements are returned in no particular order (unless this set is an instance of some class that provides a guarantee).
| |
| remove | back to summary |
|---|---|
| public boolean remove(Object key) Overrides java. Implements java. Doc from java. Removes the specified element from this set if it is present
(optional operation). More formally, removes an element
| |
| size | back to summary |
|---|---|
| public int size() Implements abstract java. Implements java. Doc from java. Returns the number of elements in this set (its cardinality). If this
set contains more than
| |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv int | |
| pack-priv LinkedTreeMap. | |
| pack-priv LinkedTreeMap. |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public final boolean | |
| pack-priv final LinkedTreeMap. | |
| public final void | remove()
Overrides default java. Removes from the underlying collection the last element returned by this iterator (optional operation). |
| expectedModCount | back to summary |
|---|---|
| pack-priv int expectedModCount | |
| lastReturned | back to summary |
|---|---|
| pack-priv LinkedTreeMap. | |
| next | back to summary |
|---|---|
| pack-priv LinkedTreeMap. | |
| LinkedTreeMapIterator | back to summary |
|---|---|
| pack-priv LinkedTreeMapIterator() | |
| hasNext | back to summary |
|---|---|
| public final boolean hasNext() Implements java. Doc from java. Returns
| |
| nextNode | back to summary |
|---|---|
pack-priv final LinkedTreeMap.
| |
| remove | back to summary |
|---|---|
| public final void remove() Overrides default java. Doc from java. Removes from the underlying collection the last element returned
by this iterator (optional operation). This method can be called
only once per call to The behavior of an iterator is unspecified if the underlying collection is modified while the iteration is in progress in any way other than by calling this method, unless an overriding class has specified a concurrent modification policy.
The behavior of an iterator is unspecified if this method is called
after a call to the
| |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv final boolean | |
| pack-priv int | |
| pack-priv final K | |
| pack-priv LinkedTreeMap. | |
| pack-priv LinkedTreeMap. | |
| pack-priv LinkedTreeMap. | |
| pack-priv LinkedTreeMap. | |
| pack-priv LinkedTreeMap. | |
| pack-priv V |
| Access | Constructor and Description |
|---|---|
| pack-priv | |
| pack-priv | Node(boolean allowNullValue, LinkedTreeMap.
Create a regular entry |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | equals(Object o)
Overrides java. Implements java. Compares the specified object with this entry for equality. |
| public LinkedTreeMap. | |
| public K | |
| public V | |
| public int | hashCode()
Overrides java. Implements java. Returns the hash code value for this map entry. |
| public LinkedTreeMap. | |
| public V | setValue(V value)
Implements java. Replaces the value corresponding to this entry with the specified value (optional operation). |
| public String |
| allowNullValue | back to summary |
|---|---|
| pack-priv final boolean allowNullValue | |
| height | back to summary |
|---|---|
| pack-priv int height | |
| key | back to summary |
|---|---|
| pack-priv final K key | |
| left | back to summary |
|---|---|
| pack-priv LinkedTreeMap. | |
| next | back to summary |
|---|---|
| pack-priv LinkedTreeMap. | |
| parent | back to summary |
|---|---|
| pack-priv LinkedTreeMap. | |
| prev | back to summary |
|---|---|
| pack-priv LinkedTreeMap. | |
| right | back to summary |
|---|---|
| pack-priv LinkedTreeMap. | |
| value | back to summary |
|---|---|
| pack-priv V value | |
| Node | back to summary |
|---|---|
| pack-priv Node(boolean allowNullValue) Create the header entry | |
| Node | back to summary |
|---|---|
| pack-priv Node(boolean allowNullValue, LinkedTreeMap. Create a regular entry | |
| equals | back to summary |
|---|---|
| public boolean equals(Object o) Overrides java. Implements java. Doc from java. Compares the specified object with this entry for equality.
Returns
(e1.getKey()==null ?
e2.getKey()==null : e1.getKey().equals(e2.getKey())) &&
(e1.getValue()==null ?
e2.getValue()==null : e1.getValue().equals(e2.getValue()))
This ensures that the equals method works properly across
different implementations of the Map.Entry interface.
| |
| first | back to summary |
|---|---|
| public LinkedTreeMap. Returns the first node in this subtree. | |
| getKey | back to summary |
|---|---|
| public K getKey() Implements java. Doc from java. Returns the key corresponding to this entry.
| |
| getValue | back to summary |
|---|---|
| public V getValue() Implements java. Doc from java. Returns the value corresponding to this entry. If the mapping
has been removed from the backing map (by the iterator's
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Implements java. Doc from java. Returns the hash code value for this map entry. The hash code
of a map entry
(e.getKey()==null ? 0 : e.getKey().hashCode()) ^
(e.getValue()==null ? 0 : e.getValue().hashCode())
This ensures that e1.equals(e2) implies that
e1.hashCode()==e2.hashCode() for any two Entries
e1 and e2, as required by the general
contract of Object.hashCode.
| |
| last | back to summary |
|---|---|
| public LinkedTreeMap. Returns the last node in this subtree. | |
| setValue | back to summary |
|---|---|
| public V setValue(V value) Implements java. Doc from java. Replaces the value corresponding to this entry with the specified
value (optional operation). (Writes through to the map.) The
behavior of this call is undefined if the mapping has already been
removed from the map (by the iterator's
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object.
Satisfying this method's contract implies a non-
| |