public class AvlBiMap<TKey extends java.lang.Comparable<TKey>,TValue extends java.lang.Comparable<TValue>> extends java.lang.Object implements IBiMap<TKey,TValue>
Constructor and Description |
---|
AvlBiMap()
Default constructor
|
AvlBiMap(java.lang.Class<?> genericTypeParameterKey,
java.lang.Class<?> genericTypeParameterValue)
Constructor for initializing with the key/value generic type parameters
|
AvlBiMap(java.util.Map<? extends TKey,? extends TValue> map)
Constructor initializes from another map
|
AvlBiMap(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
|
AvlBiMap(ReifiedMap<TKey,TValue> map)
Constructor initializes with another reified map
|
Modifier and Type | Method and Description |
---|---|
boolean |
add(TKey key,
TValue value)
Adds a key/value pair in the BiMap, returning true if succeeded.
|
void |
clear()
Removes all elements.
|
boolean |
containsKey(TKey key)
Returns true if a given key exists, false otherwise.
|
boolean |
containsValue(TValue value)
Returns true if a given value exists, false otherwise This is an O(log2(n)) operation.
|
TValue |
getByKey(TKey key)
Returns the value associated with a key, if existent.
|
TKey |
getByValue(TValue value)
Returns the key associated with a value, if existent.
|
java.lang.Class<?> |
getGenericTypeParameterKey()
Returns the TKey generic type parameter's class.
|
java.lang.Class<?> |
getGenericTypeParameterValue()
Returns the TValue generic type parameter's class.
|
java.lang.Iterable<TKey> |
getKeys()
Returns all keys in ascending key order.
|
java.lang.Iterable<TValue> |
getValues()
Returns all values in ascending value order.
|
java.util.Iterator<KeyValuePair<TKey,TValue>> |
iterator() |
boolean |
removeByKey(TKey key)
Removes an element by its key, returns true if successful.
|
boolean |
removeByValue(TValue value)
Removes an element by its value, returns true if successful.
|
boolean |
replaceByKey(TKey key,
TValue newValue)
Replaces an element's value, searching for it by key, returns true if successful.
|
boolean |
replaceByValue(TValue value,
TKey newKey)
Replaces an element's key, searching for it by value, returns true if successful.
|
int |
size()
Returns the number of items.
|
java.lang.String |
toString() |
public AvlBiMap()
SuperTypeTokenException
- When called without using anonymous class semantics.public AvlBiMap(java.lang.Class<?> genericTypeParameterKey, java.lang.Class<?> genericTypeParameterValue)
java.lang.NullPointerException
- When a generic type parameter is null.public AvlBiMap(ReifiedMap<TKey,TValue> map)
java.lang.NullPointerException
- When the argument is null, or a key or value in the map provided is null.public AvlBiMap(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 AvlBiMap(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)
public void clear()
public boolean containsKey(TKey key)
public boolean containsValue(TValue value)
public java.lang.Iterable<TKey> getKeys()
public java.lang.Iterable<TValue> getValues()
public TValue getByKey(TKey key)
public TKey getByValue(TValue value)
getByValue
in interface IBiMap<TKey extends java.lang.Comparable<TKey>,TValue extends java.lang.Comparable<TValue>>
KeyNotFoundException
- When the key is not found.public java.lang.Class<?> getGenericTypeParameterKey()
getGenericTypeParameterKey
in interface ReifiedMap<TKey extends java.lang.Comparable<TKey>,TValue extends java.lang.Comparable<TValue>>
public java.lang.Class<?> getGenericTypeParameterValue()
getGenericTypeParameterValue
in interface ReifiedMap<TKey extends java.lang.Comparable<TKey>,TValue extends java.lang.Comparable<TValue>>
public java.util.Iterator<KeyValuePair<TKey,TValue>> iterator()
iterator
in interface java.lang.Iterable<KeyValuePair<TKey extends java.lang.Comparable<TKey>,TValue extends java.lang.Comparable<TValue>>>
public boolean removeByKey(TKey key)
public boolean removeByValue(TValue value)
public boolean replaceByKey(TKey key, TValue newValue)
public boolean replaceByValue(TValue value, TKey newKey)
public int size()
public java.lang.String toString()
toString
in class java.lang.Object