Class RBTreeSortedMap<K,V> (3.9.6)

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

Inheritance

java.lang.Object > ImmutableSortedMap > RBTreeSortedMap<K,V>

Type Parameters

NameDescription
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
NameDescription
keysList<A>
valuesMap<B,C>
translatorKeyTranslator<A,B>
comparatorComparator<A>
Returns
TypeDescription
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
NameDescription
valuesMap<A,B>
comparatorComparator<A>
Returns
TypeDescription
RBTreeSortedMap<A,B>

Methods

containsKey(K key)

public boolean containsKey(K key)
Parameter
NameDescription
keyK
Returns
TypeDescription
boolean
Overrides

get(K key)

public V get(K key)
Parameter
NameDescription
keyK
Returns
TypeDescription
V
Overrides

getComparator()

public Comparator<K> getComparator()
Returns
TypeDescription
Comparator<K>
Overrides

getMaxKey()

public K getMaxKey()
Returns
TypeDescription
K
Overrides

getMinKey()

public K getMinKey()
Returns
TypeDescription
K
Overrides

getPredecessorKey(K key)

public K getPredecessorKey(K key)
Parameter
NameDescription
keyK
Returns
TypeDescription
K
Overrides

getSuccessorKey(K key)

public K getSuccessorKey(K key)
Parameter
NameDescription
keyK
Returns
TypeDescription
K
Overrides

inOrderTraversal(LLRBNode.NodeVisitor<K,V> visitor)

public void inOrderTraversal(LLRBNode.NodeVisitor<K,V> visitor)
Parameter
NameDescription
visitorNodeVisitor<K,V>
Overrides

indexOf(K key)

public int indexOf(K key)
Parameter
NameDescription
keyK
Returns
TypeDescription
int
Overrides

insert(K key, V value)

public ImmutableSortedMap<K,V> insert(K key, V value)
Parameters
NameDescription
keyK
valueV
Returns
TypeDescription
ImmutableSortedMap<K,V>
Overrides

isEmpty()

public boolean isEmpty()
Returns
TypeDescription
boolean
Overrides

iterator()

public Iterator<Map.Entry<K,V>> iterator()
Returns
TypeDescription
Iterator<Entry<K,V>>
Overrides

iteratorFrom(K key)

public Iterator<Map.Entry<K,V>> iteratorFrom(K key)
Parameter
NameDescription
keyK
Returns
TypeDescription
Iterator<Entry<K,V>>
Overrides

remove(K key)

public ImmutableSortedMap<K,V> remove(K key)
Parameter
NameDescription
keyK
Returns
TypeDescription
ImmutableSortedMap<K,V>
Overrides

reverseIterator()

public Iterator<Map.Entry<K,V>> reverseIterator()
Returns
TypeDescription
Iterator<Entry<K,V>>
Overrides

reverseIteratorFrom(K key)

public Iterator<Map.Entry<K,V>> reverseIteratorFrom(K key)
Parameter
NameDescription
keyK
Returns
TypeDescription
Iterator<Entry<K,V>>
Overrides

size()

public int size()
Returns
TypeDescription
int
Overrides