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
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)
Name | Description |
keys | List<A> |
values | Map<B,C> |
translator | KeyTranslator<A,B> |
comparator | Comparator<A> |
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)
Name | Description |
map | Map<K,V> |
comparator | Comparator<K> |
Type | Description |
ArraySortedMap<K,V> |
Constructors
ArraySortedMap(Comparator<K> comparator)
public ArraySortedMap(Comparator<K> comparator)
Name | Description |
comparator | Comparator<K> |
Methods
containsKey(K key)
public boolean containsKey(K key)
Name | Description |
key | K |
Type | Description |
boolean |
get(K key)
public V get(K key)
Name | Description |
key | K |
Type | Description |
V |
getComparator()
public Comparator<K> getComparator()
Type | Description |
Comparator<K> |
getMaxKey()
public K getMaxKey()
Type | Description |
K |
getMinKey()
public K getMinKey()
Type | Description |
K |
getPredecessorKey(K key)
public K getPredecessorKey(K key)
Name | Description |
key | K |
Type | Description |
K |
getSuccessorKey(K key)
public K getSuccessorKey(K key)
Name | Description |
key | K |
Type | Description |
K |
inOrderTraversal(LLRBNode.NodeVisitor<K,V> visitor)
public void inOrderTraversal(LLRBNode.NodeVisitor<K,V> visitor)
Name | Description |
visitor | NodeVisitor<K,V> |
indexOf(K key)
public int indexOf(K key)
Name | Description |
key | K |
Type | Description |
int |
insert(K key, V value)
public ImmutableSortedMap<K,V> insert(K key, V value)
Name | Description |
key | K |
value | V |
Type | Description |
ImmutableSortedMap<K,V> |
isEmpty()
public boolean isEmpty()
Type | Description |
boolean |
iterator()
public Iterator<Map.Entry<K,V>> iterator()
Type | Description |
Iterator<Entry<K,V>> |
iteratorFrom(K key)
public Iterator<Map.Entry<K,V>> iteratorFrom(K key)
Name | Description |
key | K |
Type | Description |
Iterator<Entry<K,V>> |
remove(K key)
public ImmutableSortedMap<K,V> remove(K key)
Name | Description |
key | K |
Type | Description |
ImmutableSortedMap<K,V> |
reverseIterator()
public Iterator<Map.Entry<K,V>> reverseIterator()
Type | Description |
Iterator<Entry<K,V>> |
reverseIteratorFrom(K key)
public Iterator<Map.Entry<K,V>> reverseIteratorFrom(K key)
Name | Description |
key | K |
Type | Description |
Iterator<Entry<K,V>> |
size()
public int size()
Type | Description |
int |