public class RBTreeSortedMap<K,V> extends ImmutableSortedMap<K,V>
This is a red-black tree backed implementation of ImmutableSortedMap. This has better asymptotic complexity for large collections, but performs worse in practice than an ArraySortedMap for small collections. It also uses about twice as much memory.
Note: This package is copied from https://github.com/firebase/firebase-admin-java/tree/master/ src/main/java/com/google/firebase/database/collection
Type Parameters | |
---|---|
Name | Description |
K | |
V |
Static Methods
<A,B,C>buildFrom(List<A> keys, Map<B,C> values, ImmutableSortedMap.Builder.KeyTranslator<A,B> translator, Comparator<A> comparator)
public static RBTreeSortedMap<A,C> <A,B,C>buildFrom(List<A> keys, Map<B,C> values, ImmutableSortedMap.Builder.KeyTranslator<A,B> translator, Comparator<A> comparator)
Parameters | |
---|---|
Name | Description |
keys | List<A> |
values | Map<B,C> |
translator | KeyTranslator<A,B> |
comparator | Comparator<A> |
Returns | |
---|---|
Type | Description |
RBTreeSortedMap<A,C> |
<A,B>fromMap(Map<A,B> values, Comparator<A> comparator)
public static RBTreeSortedMap<A,B> <A,B>fromMap(Map<A,B> values, Comparator<A> comparator)
Parameters | |
---|---|
Name | Description |
values | Map<A,B> |
comparator | Comparator<A> |
Returns | |
---|---|
Type | Description |
RBTreeSortedMap<A,B> |
Methods
containsKey(K key)
public boolean containsKey(K key)
Parameter | |
---|---|
Name | Description |
key | K |
Returns | |
---|---|
Type | Description |
boolean |
get(K key)
public V get(K key)
Parameter | |
---|---|
Name | Description |
key | K |
Returns | |
---|---|
Type | Description |
V |
getComparator()
public Comparator<K> getComparator()
Returns | |
---|---|
Type | Description |
Comparator<K> |
getMaxKey()
public K getMaxKey()
Returns | |
---|---|
Type | Description |
K |
getMinKey()
public K getMinKey()
Returns | |
---|---|
Type | Description |
K |
getPredecessorKey(K key)
public K getPredecessorKey(K key)
Parameter | |
---|---|
Name | Description |
key | K |
Returns | |
---|---|
Type | Description |
K |
getSuccessorKey(K key)
public K getSuccessorKey(K key)
Parameter | |
---|---|
Name | Description |
key | K |
Returns | |
---|---|
Type | Description |
K |
inOrderTraversal(LLRBNode.NodeVisitor<K,V> visitor)
public void inOrderTraversal(LLRBNode.NodeVisitor<K,V> visitor)
Parameter | |
---|---|
Name | Description |
visitor | NodeVisitor<K,V> |
indexOf(K key)
public int indexOf(K key)
Parameter | |
---|---|
Name | Description |
key | K |
Returns | |
---|---|
Type | Description |
int |
insert(K key, V value)
public ImmutableSortedMap<K,V> insert(K key, V value)
Parameters | |
---|---|
Name | Description |
key | K |
value | V |
Returns | |
---|---|
Type | Description |
ImmutableSortedMap<K,V> |
isEmpty()
public boolean isEmpty()
Returns | |
---|---|
Type | Description |
boolean |
iterator()
public Iterator<Map.Entry<K,V>> iterator()
Returns | |
---|---|
Type | Description |
Iterator<Entry<K,V>> |
iteratorFrom(K key)
public Iterator<Map.Entry<K,V>> iteratorFrom(K key)
Parameter | |
---|---|
Name | Description |
key | K |
Returns | |
---|---|
Type | Description |
Iterator<Entry<K,V>> |
remove(K key)
public ImmutableSortedMap<K,V> remove(K key)
Parameter | |
---|---|
Name | Description |
key | K |
Returns | |
---|---|
Type | Description |
ImmutableSortedMap<K,V> |
reverseIterator()
public Iterator<Map.Entry<K,V>> reverseIterator()
Returns | |
---|---|
Type | Description |
Iterator<Entry<K,V>> |
reverseIteratorFrom(K key)
public Iterator<Map.Entry<K,V>> reverseIteratorFrom(K key)
Parameter | |
---|---|
Name | Description |
key | K |
Returns | |
---|---|
Type | Description |
Iterator<Entry<K,V>> |
size()
public int size()
Returns | |
---|---|
Type | Description |
int |