public class SharedAvlHashtable<TKey extends java.lang.Comparable<TKey>,TValue> extends java.lang.Object implements ISharedHashtable<TKey,TValue>
Constructor and Description |
---|
SharedAvlHashtable()
Default constructor
|
SharedAvlHashtable(java.lang.Class<?> genericTypeParameterKey,
java.lang.Class<?> genericTypeParameterValue)
Constructor for initializing with the key/value generic type parameters
|
SharedAvlHashtable(java.util.Map<? extends TKey,? extends TValue> map)
Constructor initializes from another map
|
SharedAvlHashtable(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
|
SharedAvlHashtable(ReifiedMap<TKey,TValue> map)
Constructor initializes with another reified map
|
Modifier and Type | Method and Description |
---|---|
boolean |
add(TKey key,
TValue value)
Adds a new key/value pair.
|
java.lang.Iterable<java.lang.Boolean> |
addRange(java.lang.Iterable<? extends TKey> keys,
java.lang.Iterable<? extends TValue> values)
Bulk add key/value pairs to avoid locking/unlocking continuously.
|
void |
clear()
Removes all keys and values.
|
boolean |
contains(TKey key)
Returns the value of a key, if found.
|
TValue |
get(TKey key)
Attempts to get the given key's value.
|
TValue |
get(TKey key,
TValue defaultValue)
Returns the value of a key, if found.
|
java.lang.Class<?> |
getGenericTypeParameterKey()
Returns the TKey generic type parameter's class.
|
java.lang.Class<?> |
getGenericTypeParameterValue()
Returns the TValue generic type parameter's class.
|
ReifiedIterable<TKey> |
getKeys()
Returns a copy of all keys
|
ReifiedIterable<TValue> |
getValues()
Returns a copy of all values
|
java.util.Iterator<KeyValuePair<TKey,TValue>> |
iterator()
Returns all key/value pairs in a list copy of key/value pairs.
|
void |
lock()
Locks the collection
|
boolean |
remove(TKey key)
Removes a value by its key.
|
TValue |
removeAndGet(TKey key)
If the key is contained, the key/value pair is removed and the value returned.
|
TValue |
removeAndGet(TKey key,
TValue defaultValue)
If the key is contained, the key/value pair is removed and the value returned.
|
java.lang.Iterable<java.lang.Boolean> |
removeRange(java.lang.Iterable<? extends TKey> keys)
Removes a number of elements by key.
|
boolean |
replace(TKey key,
TValue newValue)
Replaces a key's value, returning true if this was successful.
|
java.lang.Iterable<java.lang.Boolean> |
replaceAll(java.lang.Iterable<? extends TKey> keys,
java.lang.Iterable<? extends TValue> values)
Clears the hashtable and bulk adds key/value pairs to avoid locking/unlocking continuously.
|
int |
size()
Returns the size of the AVL hashtable.
|
java.lang.String |
toString() |
void |
unlock()
Unlocks the collection.
|
public SharedAvlHashtable()
SuperTypeTokenException
- When called without using anonymous class semantics.public SharedAvlHashtable(java.lang.Class<?> genericTypeParameterKey, java.lang.Class<?> genericTypeParameterValue)
java.lang.NullPointerException
- When a generic type parameter is null.public SharedAvlHashtable(ReifiedMap<TKey,TValue> map)
java.lang.NullPointerException
- When the argument is null, or a key in the map provided is null.public SharedAvlHashtable(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 SharedAvlHashtable(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 boolean add(TKey key, TValue value)
add
in interface ISharedHashtable<TKey extends java.lang.Comparable<TKey>,TValue>
java.lang.NullPointerException
- When the key is null.public java.lang.Iterable<java.lang.Boolean> addRange(java.lang.Iterable<? extends TKey> keys, java.lang.Iterable<? extends TValue> values)
addRange
in interface ISharedHashtable<TKey extends java.lang.Comparable<TKey>,TValue>
java.lang.NullPointerException
- When the keys or values argument is null.java.lang.IllegalArgumentException
- When the key count is not equal to the value count in the provided sequences.public void clear()
clear
in interface ISharedHashtable<TKey extends java.lang.Comparable<TKey>,TValue>
public boolean contains(TKey key)
contains
in interface ISharedHashtable<TKey extends java.lang.Comparable<TKey>,TValue>
java.lang.NullPointerException
- When the key is null.public TValue get(TKey key)
get
in interface ISharedHashtable<TKey extends java.lang.Comparable<TKey>,TValue>
java.lang.NullPointerException
- When the key is null.public TValue get(TKey key, TValue defaultValue)
get
in interface ISharedHashtable<TKey extends java.lang.Comparable<TKey>,TValue>
java.lang.NullPointerException
- When the key is null.public ReifiedIterable<TKey> getKeys()
getKeys
in interface ISharedHashtable<TKey extends java.lang.Comparable<TKey>,TValue>
public ReifiedIterable<TValue> getValues()
getValues
in interface ISharedHashtable<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 java.util.Iterator<KeyValuePair<TKey,TValue>> iterator()
iterator
in interface java.lang.Iterable<KeyValuePair<TKey extends java.lang.Comparable<TKey>,TValue>>
public boolean remove(TKey key)
remove
in interface ISharedHashtable<TKey extends java.lang.Comparable<TKey>,TValue>
java.lang.NullPointerException
- When the key is null.public java.lang.Iterable<java.lang.Boolean> removeRange(java.lang.Iterable<? extends TKey> keys)
removeRange
in interface ISharedHashtable<TKey extends java.lang.Comparable<TKey>,TValue>
java.lang.NullPointerException
- When the keys argument is null.public TValue removeAndGet(TKey key)
java.lang.NullPointerException
- When the key is null.public TValue removeAndGet(TKey key, TValue defaultValue)
removeAndGet
in interface ISharedHashtable<TKey extends java.lang.Comparable<TKey>,TValue>
java.lang.NullPointerException
- When the key is null.public boolean replace(TKey key, TValue newValue)
replace
in interface ISharedHashtable<TKey extends java.lang.Comparable<TKey>,TValue>
java.lang.NullPointerException
- When the key is null.public java.lang.Iterable<java.lang.Boolean> replaceAll(java.lang.Iterable<? extends TKey> keys, java.lang.Iterable<? extends TValue> values)
replaceAll
in interface ISharedHashtable<TKey extends java.lang.Comparable<TKey>,TValue>
java.lang.NullPointerException
- When the keys or values argument is null.java.lang.IllegalArgumentException
- When the key count is not equal to the value count in the given collections.public int size()
size
in interface ISharedHashtable<TKey extends java.lang.Comparable<TKey>,TValue>
size
in interface ReifiedMap<TKey extends java.lang.Comparable<TKey>,TValue>
public java.lang.String toString()
toString
in class java.lang.Object