V - The type of the IndexEntries.public class AvlTreeIndex<V extends SortedIndex.IndexEntry> extends java.lang.Object implements SortedIndex<V>
Note: This class is not thread-safe and requires external synchronization when in a multi-threaded environment.
SortedIndex.IndexEntry| Constructor and Description |
|---|
AvlTreeIndex()
Creates a new instance of the AvlTreeIndex class.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Clears the contents of the Index.
|
void |
forEach(java.util.function.Consumer<V> consumer)
Iterates through each item in the Index, in natural order, and calls the given consumer on all of them.
|
V |
get(long key)
Gets an item with the given key.
|
V |
getCeiling(long key)
Gets the smallest item whose key is greater than or equal to the given key.
|
V |
getFirst()
Gets the smallest item in the index.
|
V |
getFloor(long key)
Gets the largest item whose key is smaller than or equal to the given key.
|
V |
getLast()
Gets the largest item in the index.
|
V |
put(V item)
Inserts the given item into the Index.
|
V |
remove(long key)
Removes any item with the given key from the Index.
|
int |
size()
Gets a value indicating the number of items in the Index.
|
public AvlTreeIndex()
public void clear()
SortedIndexclear in interface SortedIndex<V extends SortedIndex.IndexEntry>public V put(V item)
SortedIndexput in interface SortedIndex<V extends SortedIndex.IndexEntry>item - The item to insert.public V remove(long key)
SortedIndexremove in interface SortedIndex<V extends SortedIndex.IndexEntry>key - The key of the item to remove.public int size()
SortedIndexsize in interface SortedIndex<V extends SortedIndex.IndexEntry>public V get(long key)
SortedIndexget in interface SortedIndex<V extends SortedIndex.IndexEntry>key - The key to search by.public V getCeiling(long key)
SortedIndexgetCeiling in interface SortedIndex<V extends SortedIndex.IndexEntry>key - the Key to search by.public V getFloor(long key)
SortedIndexgetFloor in interface SortedIndex<V extends SortedIndex.IndexEntry>key - the Key to search by.public V getFirst()
SortedIndexgetFirst in interface SortedIndex<V extends SortedIndex.IndexEntry>public V getLast()
SortedIndexgetLast in interface SortedIndex<V extends SortedIndex.IndexEntry>public void forEach(java.util.function.Consumer<V> consumer)
SortedIndexforEach in interface SortedIndex<V extends SortedIndex.IndexEntry>consumer - The consumer to invoke.