public class AvlHashtable<TKey extends java.lang.Comparable<TKey>,TValue> extends java.lang.Object implements IHashtable<TKey,TValue>
Constructor and Description |
---|
AvlHashtable()
Default constructor
|
AvlHashtable(java.lang.Class<?> genericTypeParameterKey,
java.lang.Class<?> genericTypeParameterValue)
Constructor for initializing with the key/value generic type parameters
|
AvlHashtable(java.util.Map<? extends TKey,? extends TValue> map)
Constructor initializes from another map
|
AvlHashtable(java.util.Map<? extends TKey,? extends TValue> map,
java.lang.Class<?> genericTypeParameterKey,
java.lang.Class<?> genericTypeParameterValue)
Constructor initializes from another map and the list-map's key/value generic type parameters
|
AvlHashtable(ReifiedMap<TKey,TValue> map)
Constructor initializes with another reified map
|
Modifier and Type | Method and Description |
---|---|
void |
add(KeyValuePair<? extends TKey,? extends TValue> kvp)
Adds an element represented by the provided key/value pair if the key is not already present.
|
boolean |
add(TKey key,
TValue value)
Adds the provided key/value pair if the key is not already present.
|
void |
clear()
Removes all elements from this AVL hash table.
|
boolean |
contains(KeyValuePair<? extends TKey,? extends TValue> kvp)
Returns true if a key exists in the key collection.
|
boolean |
containsKey(TKey key)
Returns true if the key of the key/value pair exists in the key collection.
|
TValue |
get(TKey key)
Gets the value associated with the specified key.
|
java.lang.Class<?> |
getGenericTypeParameterKey()
Returns the TKey generic type parameter's class.
|
java.lang.Class<?> |
getGenericTypeParameterValue()
Returns the TValue generic type parameter's class.
|
KeyCollection<TKey,TValue> |
getKeys()
Gets a collection containing the keys in the AVL hashtable.
|
ValueCollection<TKey,TValue> |
getValues()
Gets a collection containing the values in the
Returns the values of all key/value pairs, in ascending key order.
|
java.util.Iterator<KeyValuePair<TKey,TValue>> |
iterator()
Returns an iterator of key/value pairs.
|
boolean |
remove(KeyValuePair<? extends TKey,? extends TValue> kvp)
Removes a key/value pair based on its key.
|
boolean |
remove(TKey key)
Removes the value associated with the specified key.
|
boolean |
replace(TKey key,
TValue value)
Replaces a key's value with the specified value.
|
int |
size()
Gets the number of key/value pairs contained in the AVL hashtable.
|
TryResult<TValue> |
tryGetValue(TKey key)
Attempts to get a value by a given key.
|
public AvlHashtable()
SuperTypeTokenException
- When called without using anonymous class semantics.public AvlHashtable(java.lang.Class<?> genericTypeParameterKey, java.lang.Class<?> genericTypeParameterValue)
java.lang.NullPointerException
- When a generic type parameter is null.public AvlHashtable(ReifiedMap<TKey,TValue> map)
java.lang.NullPointerException
- When the argument is null, or a key in the map provided is null.public AvlHashtable(java.util.Map<? extends TKey,? extends TValue> map)
SuperTypeTokenException
- When called without using anonymous class semantics.java.lang.NullPointerException
- When the argument is null.public AvlHashtable(java.util.Map<? extends TKey,? extends TValue> map, java.lang.Class<?> genericTypeParameterKey, java.lang.Class<?> genericTypeParameterValue)
java.lang.NullPointerException
- When an argument is null.public void add(KeyValuePair<? extends TKey,? extends TValue> kvp)
add
in interface IHashtable<TKey extends java.lang.Comparable<TKey>,TValue>
kvp
- The key/value pair to add.java.lang.NullPointerException
- If the key value pair or the key is null.public boolean add(TKey key, TValue value)
add
in interface IHashtable<TKey extends java.lang.Comparable<TKey>,TValue>
key
- The key to add.value
- The value to add.java.lang.NullPointerException
- If the key is null.public void clear()
clear
in interface IHashtable<TKey extends java.lang.Comparable<TKey>,TValue>
public boolean contains(KeyValuePair<? extends TKey,? extends TValue> kvp)
contains
in interface IHashtable<TKey extends java.lang.Comparable<TKey>,TValue>
kvp
- A key value pair (only the key is used).java.lang.NullPointerException
- If the key is null.public boolean containsKey(TKey key)
containsKey
in interface IHashtable<TKey extends java.lang.Comparable<TKey>,TValue>
key
- The key to find.java.lang.NullPointerException
- If the key is null.public TValue get(TKey key)
get
in interface IHashtable<TKey extends java.lang.Comparable<TKey>,TValue>
key
- The key to find.java.lang.NullPointerException
- When the key is null.KeyNotFoundException
- When the key does not exist.public KeyCollection<TKey,TValue> getKeys()
getKeys
in interface IHashtable<TKey extends java.lang.Comparable<TKey>,TValue>
public ValueCollection<TKey,TValue> getValues()
getValues
in interface IHashtable<TKey extends java.lang.Comparable<TKey>,TValue>
public java.util.Iterator<KeyValuePair<TKey,TValue>> iterator()
iterator
in interface java.lang.Iterable<KeyValuePair<TKey extends java.lang.Comparable<TKey>,TValue>>
public boolean remove(KeyValuePair<? extends TKey,? extends TValue> kvp)
remove
in interface IHashtable<TKey extends java.lang.Comparable<TKey>,TValue>
kvp
- The key/value pair (only the key is used).java.lang.NullPointerException
- If the key/value pair or the key is null.public boolean remove(TKey key)
remove
in interface IHashtable<TKey extends java.lang.Comparable<TKey>,TValue>
key
- The key to find.java.lang.NullPointerException
- If the key is null.public boolean replace(TKey key, TValue value)
replace
in interface IHashtable<TKey extends java.lang.Comparable<TKey>,TValue>
key
- The key to find.value
- The new value.java.lang.NullPointerException
- When the key is null.public int size()
size
in interface IHashtable<TKey extends java.lang.Comparable<TKey>,TValue>
size
in interface ReifiedMap<TKey extends java.lang.Comparable<TKey>,TValue>
public java.lang.Class<?> getGenericTypeParameterKey()
getGenericTypeParameterKey
in interface ReifiedMap<TKey extends java.lang.Comparable<TKey>,TValue>
public java.lang.Class<?> getGenericTypeParameterValue()
getGenericTypeParameterValue
in interface ReifiedMap<TKey extends java.lang.Comparable<TKey>,TValue>
public TryResult<TValue> tryGetValue(TKey key)
tryGetValue
in interface IHashtable<TKey extends java.lang.Comparable<TKey>,TValue>
key
- The key to find.java.lang.NullPointerException
- When the key is null.