TreePMap, and as the element type for
TreePSet. This class provides various methods that maintain the ordering and
distinctness of keys based on a client-provided instance of Comparator<? super K>.
TreePMap. (Is ignored by TreePSet.)
PSortedMap and PSortedSet, namely TreePMap and TreePSet. Each instance of this class is both a
(sub)tree (with a host of methods for examining and manipulating that tree) and the node at the
root of that (sub)tree (implementing V> and providing methods getKey() and getValue() to retrieve the mapping at the node). Method Javadoc refers to
'this node' or 'this tree' as appropriate.
All operations are guaranteed to complete within O(log n) time. A complete iteration pass over entryIterator(boolean) completes in O(n) time. A few operations -- namely getKey, getValue, isEmpty, orNullIfEmpty, and size -- complete in O(1) time.
| Modifier and Type | Class and Description |
|---|---|
| private static class | |
| private static enum | KVTree.
Whether an iterator returns entries or just keys. |
| pack-priv static enum |
| Modifier and Type | Field and Description |
|---|---|
| private static final KVTree | EMPTY
The empty tree / leaf node. |
| private final int | height
The height of this tree: 0 if this tree is empty, otherwise 1 + max(left.height, right.height). |
| private final K | |
| private final KVTree | |
| private final KVTree | |
| private static final long | |
| private final int | |
| private final V |
| Access | Constructor and Description |
|---|---|
| private | |
| private |
| Modifier and Type | Method and Description |
|---|---|
| private void | |
| private static <K, V> KVTree | |
| pack-priv static <K, V> KVTree | |
| pack-priv Iterator | Returns: An iterator over the mappings in this tree in the specified direction.- True if to iterate from left to right; false for right to left. isLeftToRight)Creates an iterator over the mappings in this tree. |
| public boolean | equals(final Object
object to be compared for equality with this map entry o)Overrides java. Implements java. Implements equals(...) as specified by Map.Entry. |
| pack-priv static <K, V> KVTree | |
| private static <K, V> KVTree | fromIterator(final Iterator<?> iterator, final KVTree.
|
| pack-priv static <K, V> KVTree | |
| public K | Returns: This node's key, or null if this node is the root of the empty tree.Implements java. Returns the key corresponding to this entry. |
| pack-priv KVTree | |
| pack-priv KVTree | |
| public V | Returns: This node's value (which may be null), or null if this node is the root of the empty tree.Implements java. Returns the value corresponding to this entry. |
| public int | hashCode()
Overrides java. Implements java. implements hashCode() as specified by Map.Entry |
| pack-priv boolean | |
| private static <K, V> KVTree | Returns: A tree containing the specified mappings in the specified order.Creates a tree consisting of all the mappings of 'left', in order, followed by a mapping from 'key' to 'value', followed by all the mappings of 'right', in order. |
| pack-priv KVTree | |
| pack-priv KVTree | |
| pack-priv KVTree | |
| pack-priv Map. | |
| pack-priv KVTree | |
| pack-priv KVTree | range(final K leftBound, final boolean isLeftBoundInclusive, final K rightBound, final boolean isRightBoundInclusive, final Comparator<? super K> comparator)
|
| pack-priv KVTree | rangeToLeft(final K rightBound, final boolean isRightBoundInclusive, final Comparator<? super K> comparator)
|
| pack-priv KVTree | rangeToRight(final K leftBound, final boolean isleftBoundInclusive, final Comparator<? super K> comparator)
|
| private Object | |
| private KVTree | |
| private KVTree | |
| private KVTree | |
| pack-priv KVTree | |
| public V | setValue(final V
new value to be stored in this entry value)Implements java.
Deprecated
Unsupported operation.
Replaces the value corresponding to this entry with the specified value (optional operation). |
| pack-priv int | |
| public String | toString()
Overrides java. implements toString() in a form expected for an implementation of Map.Entry, namely "KEY=VALUE" (with no information about the presence or absence of child nodes). |
| EMPTY | back to summary |
|---|---|
| private static final KVTree<?, ?> EMPTY The empty tree / leaf node. Access via | |
| height | back to summary |
|---|---|
| private final int height The height of this tree: 0 if this tree is empty, otherwise 1 + max(left.height, right.height). | |
| key | back to summary |
|---|---|
| private final K key | |
| left | back to summary |
|---|---|
| private final KVTree<K, V> left | |
| right | back to summary |
|---|---|
| private final KVTree<K, V> right | |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID | |
| size | back to summary |
|---|---|
| private final int size | |
| value | back to summary |
|---|---|
| private final V value | |
| KVTree | back to summary |
|---|---|
| private KVTree() Constructor for the empty tree / leaf node | |
| KVTree | back to summary |
|---|---|
| private KVTree(final KVTree<K, V> left, final K key, final V value, final KVTree<K, V> right) Constructor for a non-empty/non-leaf node. Only intended to be called via | |
| checkNotEmpty | back to summary |
|---|---|
| private void checkNotEmpty() | |
| concat | back to summary |
|---|---|
| private static <K, V> KVTree | |
| empty | back to summary |
|---|---|
pack-priv static <K, V> KVTree
| |
| entryIterator | back to summary |
|---|---|
| pack-priv Iterator Creates an iterator over the mappings in this tree. | |
| equals | back to summary |
|---|---|
| public boolean equals(final Object o) Overrides java. Implements java. Implements equals(...) as specified by Map.Entry.
| |
| fromEntryIterator | back to summary |
|---|---|
| pack-priv static <K, V> KVTree | |
| fromIterator | back to summary |
|---|---|
| private static <K, V> KVTree | |
| fromKeyIterator | back to summary |
|---|---|
| pack-priv static <K, V> KVTree | |
| getKey | back to summary |
|---|---|
| public K getKey() Implements java. Doc from java. Returns the key corresponding to this entry.
| |
| getLeftmost | back to summary |
|---|---|
pack-priv KVTree
| |
| getRightmost | back to summary |
|---|---|
pack-priv KVTree
| |
| 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. implements hashCode() as specified by Map.Entry
| |
| isEmpty | back to summary |
|---|---|
pack-priv boolean isEmpty()
| |
| join | back to summary |
|---|---|
| private static <K, V> KVTree Creates a tree consisting of all the mappings of 'left', in order, followed by a mapping from
'key' to 'value', followed by all the mappings of 'right', in order. Handles any necessary
rebalancing if 'left' and 'right' have mismatched heights. (The intention is that this method
be the only code that calls Requires time proportional to the difference in heights between 'left' and 'right', which is in O(log(max(left.size, right.size))) = O(log(left.size + right.size)). The height of the returned tree is guaranteed to be max(left.height, right.height) plus either zero or one. (This is important in ensuring the time guarantees of this method and of methods that call it.)
| |
| minus | back to summary |
|---|---|
| pack-priv KVTree | |
| minusLeftmost | back to summary |
|---|---|
pack-priv KVTree
| |
| minusRightmost | back to summary |
|---|---|
pack-priv KVTree
| |
| orNullIfEmpty | back to summary |
|---|---|
| pack-priv Map. | |
| plus | back to summary |
|---|---|
| pack-priv KVTree | |
| range | back to summary |
|---|---|
| pack-priv KVTree | |
| rangeToLeft | back to summary |
|---|---|
| pack-priv KVTree | |
| rangeToRight | back to summary |
|---|---|
| pack-priv KVTree | |
| readResolve | back to summary |
|---|---|
| private Object readResolve() | |
| replaceLeft | back to summary |
|---|---|
| private KVTree | |
| replaceRight | back to summary |
|---|---|
| private KVTree | |
| replaceValue | back to summary |
|---|---|
| private KVTree | |
| search | back to summary |
|---|---|
| pack-priv KVTree | |
| setValue | back to summary |
|---|---|
| public V setValue(final V value) Implements java. Doc from java. Deprecated Unsupported operation. 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
| |
| size | back to summary |
|---|---|
pack-priv int size()
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. implements toString() in a form expected for an implementation of Map.Entry, namely "KEY=VALUE" (with no information about the presence or absence of child nodes).
| |
| Modifier and Type | Field and Description |
|---|---|
| private final boolean | isLeftToRight
whether we're iterating from left to right (vs. right to left) |
| private KVTree | nextSubtree
node that we need to enter |
| private final ArrayList | stack
nodes that we've recursed into, but not yet returned |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| private KVTree | |
| public boolean | |
| public Map. | |
| private KVTree |
| isLeftToRight | back to summary |
|---|---|
| private final boolean isLeftToRight whether we're iterating from left to right (vs. right to left) | |
| nextSubtree | back to summary |
|---|---|
| private KVTree<K, V> nextSubtree node that we need to enter | |
| stack | back to summary |
|---|---|
| private final ArrayList<KVTree<K, V>> stack nodes that we've recursed into, but not yet returned | |
| EntryIterator | back to summary |
|---|---|
| pack-priv EntryIterator(final KVTree<K, V> tree, final boolean isLeftToRight) | |
| firstChild | back to summary |
|---|---|
| private KVTree | |
| hasNext | back to summary |
|---|---|
| public boolean hasNext() Implements java. Doc from java. Returns
| |
| next | back to summary |
|---|---|
| public Map. Implements java. Doc from java. Returns the next element in the iteration. | |
| secondChild | back to summary |
|---|---|
| private KVTree | |
fromEntryIterator(Iterator) and fromKeyIterator(Iterator) share code. A cleaner
alternative would be to wrap the key iterator in an entry iterator; but that would create lots
of unnecessary Map.Entry instances.)
| Modifier and Type | Field and Description |
|---|---|
| public static final KVTree. | |
| public static final KVTree. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static KVTree. | |
| public static KVTree. |
| ENTRY | back to summary |
|---|---|
| public static final KVTree. | |
| KEY | back to summary |
|---|---|
| public static final KVTree. | |
| IteratorType | back to summary |
|---|---|
| private IteratorType() | |
| valueOf | back to summary |
|---|---|
| public static KVTree. | |
| values | back to summary |
|---|---|
| public static KVTree. | |
| Modifier and Type | Field and Description |
|---|---|
| public static final KVTree. | |
| public static final KVTree. | |
| public static final KVTree. | |
| public static final KVTree. | |
| public static final KVTree. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static KVTree. | |
| public static KVTree. |
| EQ | back to summary |
|---|---|
| public static final KVTree. | |
| GE | back to summary |
|---|---|
| public static final KVTree. | |
| GT | back to summary |
|---|---|
| public static final KVTree. | |
| LE | back to summary |
|---|---|
| public static final KVTree. | |
| LT | back to summary |
|---|---|
| public static final KVTree. | |
| SearchType | back to summary |
|---|---|
| private SearchType() | |
| valueOf | back to summary |
|---|---|
| public static KVTree. | |
| values | back to summary |
|---|---|
| public static KVTree. | |