Class ArraySortedMap<K,V> (3.21.4)

public class ArraySortedMap<K,V> extends ImmutableSortedMap<K,V>

This is an array backed implementation of ImmutableSortedMap. It uses arrays and linear lookups to achieve good memory efficiency while maintaining good performance for small collections. To avoid degrading performance with increasing collection size it will automatically convert to a RBTreeSortedMap after an insert call above a certain threshold.

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 > ArraySortedMap<K,V>

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 ArraySortedMap<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
ArraySortedMap<A,C>

<K,V>fromMap(Map<K,V> map, Comparator<K> comparator)

public static ArraySortedMap<K,V> <K,V>fromMap(Map<K,V> map, Comparator<K> comparator)
Parameters
Name Description
map Map<K,V>
comparator Comparator<K>
Returns
Type Description
ArraySortedMap<K,V>

Constructors

ArraySortedMap(Comparator<K> comparator)

public ArraySortedMap(Comparator<K> comparator)
Parameter
Name Description
comparator Comparator<K>

Methods

containsKey(K key)

public boolean containsKey(K key)
Parameter
Name Description
key K
Returns
Type Description
boolean
Overrides

get(K key)

public V get(K key)
Parameter
Name Description
key K
Returns
Type Description
V
Overrides

getComparator()

public Comparator<K> getComparator()
Returns
Type Description
Comparator<K>
Overrides

getMaxKey()

public K getMaxKey()
Returns
Type Description
K
Overrides

getMinKey()

public K getMinKey()
Returns
Type Description
K
Overrides

getPredecessorKey(K key)

public K getPredecessorKey(K key)
Parameter
Name Description
key K
Returns
Type Description
K
Overrides

getSuccessorKey(K key)

public K getSuccessorKey(K key)
Parameter
Name Description
key K
Returns
Type Description
K
Overrides

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

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

indexOf(K key)

public int indexOf(K key)
Parameter
Name Description
key K
Returns
Type Description
int
Overrides

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>
Overrides

isEmpty()

public boolean isEmpty()
Returns
Type Description
boolean
Overrides

iterator()

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

iteratorFrom(K key)

public Iterator<Map.Entry<K,V>> iteratorFrom(K key)
Parameter
Name Description
key K
Returns
Type Description
Iterator<Entry<K,V>>
Overrides

remove(K key)

public ImmutableSortedMap<K,V> remove(K key)
Parameter
Name Description
key K
Returns
Type Description
ImmutableSortedMap<K,V>
Overrides

reverseIterator()

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

reverseIteratorFrom(K key)

public Iterator<Map.Entry<K,V>> reverseIteratorFrom(K key)
Parameter
Name Description
key K
Returns
Type Description
Iterator<Entry<K,V>>
Overrides

size()

public int size()
Returns
Type Description
int
Overrides