public class AvlTreeMapImpl<K,V> extends Object implements AvlTreeMap<K,V>
| Constructor and Description |
|---|
AvlTreeMapImpl(Comparator<K> keyComparator,
Comparator<V> valueComparator)
Creates a new instance of AVLTreeMap without support for duplicate keys.
|
AvlTreeMapImpl(Comparator<K> keyComparator,
Comparator<V> valueComparator,
boolean allowDuplicates)
Creates a new instance of AVLTreeMap without support for duplicate keys.
|
| Modifier and Type | Method and Description |
|---|---|
LinkedAvlMapNode<K,V> |
find(K key)
Find a LinkedAvlMapNode with the given key value in the tree.
|
LinkedAvlMapNode<K,V> |
find(K key,
V value)
Find a LinkedAvlMapNode with the given key and value in the tree.
|
LinkedAvlMapNode<K,V> |
findGreater(K key)
Finds a LinkedAvlMapNode
|
LinkedAvlMapNode<K,V> |
findGreaterOrEqual(K key)
Finds a LinkedAvlMapNode
|
LinkedAvlMapNode<K,V> |
findLess(K key)
Finds a LinkedAvlMapNode
|
LinkedAvlMapNode<K,V> |
findLessOrEqual(K key)
Finds a LinkedAvlMapNode
|
LinkedAvlMapNode<K,V> |
getFirst() |
Comparator<K> |
getKeyComparator() |
List<K> |
getKeys() |
LinkedAvlMapNode<K,V> |
getLast() |
LinkedAvlMapNode<K,V> |
getRoot() |
int |
getSize()
returns the number of nodes present in this tree.
|
Comparator<V> |
getValueComparator() |
V |
insert(K key,
V value)
Inserts a LinkedAvlMapNode with the given key and value.
|
boolean |
isDupsAllowed()
tells if the duplicate keys are supported or not.
|
boolean |
isEmpty()
Tests if the tree is logically empty.
|
void |
printTree()
Prints the contents of AVL tree in pretty format
|
SingletonOrOrderedSet<V> |
remove(K key)
Removes a node associated with the given key
The entire node will be removed irrespective of whether duplicate keys
are enabled or not
|
V |
remove(K key,
V value)
Removes the LinkedAvlMapNode present in the tree with the given key and value
|
void |
removeAll()
removes all the nodes from the tree
|
public AvlTreeMapImpl(Comparator<K> keyComparator, Comparator<V> valueComparator)
keyComparator - the comparator to be used for comparing keysvalueComparator - the comparator to be used for comparing valuespublic AvlTreeMapImpl(Comparator<K> keyComparator, Comparator<V> valueComparator, boolean allowDuplicates)
keyComparator - the comparator to be used for comparing keysvalueComparator - the comparator to be used for comparing valuesallowDuplicates - are duplicates keyComparators allowed?public Comparator<K> getKeyComparator()
getKeyComparator in interface AvlTreeMap<K,V>public Comparator<V> getValueComparator()
getValueComparator in interface AvlTreeMap<K,V>public V insert(K key, V value)
insert in interface AvlTreeMap<K,V>key - the item to be insertedvalue - the value associated with the keypublic SingletonOrOrderedSet<V> remove(K key)
remove in interface AvlTreeMap<K,V>key - the key of the node to be removedpublic V remove(K key, V value)
remove in interface AvlTreeMap<K,V>key - the key of the node to be removedvalue - the value of the nodepublic boolean isEmpty()
isEmpty in interface AvlTreeMap<K,V>public int getSize()
getSize in interface AvlTreeMap<K,V>public LinkedAvlMapNode<K,V> getRoot()
getRoot in interface AvlTreeMap<K,V>public List<K> getKeys()
getKeys in interface AvlTreeMap<K,V>public void printTree()
printTree in interface AvlTreeMap<K,V>public LinkedAvlMapNode<K,V> getFirst()
getFirst in interface AvlTreeMap<K,V>public LinkedAvlMapNode<K,V> getLast()
getLast in interface AvlTreeMap<K,V>public LinkedAvlMapNode<K,V> findGreater(K key)
findGreater in interface AvlTreeMap<K,V>key - the keypublic LinkedAvlMapNode<K,V> findGreaterOrEqual(K key)
findGreaterOrEqual in interface AvlTreeMap<K,V>key - the keypublic LinkedAvlMapNode<K,V> findLess(K key)
findLess in interface AvlTreeMap<K,V>key - the keypublic LinkedAvlMapNode<K,V> findLessOrEqual(K key)
findLessOrEqual in interface AvlTreeMap<K,V>key - the keypublic LinkedAvlMapNode<K,V> find(K key)
find in interface AvlTreeMap<K,V>key - the key to findpublic LinkedAvlMapNode<K,V> find(K key, V value)
find in interface AvlTreeMap<K,V>key - the key of the nodevalue - the value of the nodepublic boolean isDupsAllowed()
isDupsAllowed in interface AvlTreeMap<K,V>public void removeAll()
Copyright © 2021. All rights reserved.