|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jjoost.collections.bimaps.AbstractBiMap<K,V,M,I>
public abstract class AbstractBiMap<K,V,M extends AnyMap<K,V>,I extends AnyMap<V,K>>
| Method Summary | |
|---|---|
boolean |
add(K key,
V val)
Attempt to add the pair to the map, returning false if it could not be added, and true otherwise. |
int |
clear()
Clears the map, returning the number of elements removed from it. |
java.util.Iterator<java.util.Map.Entry<K,V>> |
clearAndReturn()
Clears the map, returning the entries removed from it. |
boolean |
contains(K key)
Returns true iff a key occurs in the map which is equal to the parameter, as determined by the map's definition of equality. |
boolean |
contains(K key,
V val)
Returns true iff a (key,value) pair occurs in the map that is equal to those provided, as determined by the map's definition(s) of equality. |
int |
count(K key)
Returns the number of occurrences of keys present in the map that are equal to the one provided, as determined by the map's definition of equality. |
int |
count(K key,
V val)
Returns the number of occurrences of (key, value) pairs present in the map that are equal to the one provided, as determined by the map's definition(s) of equality. |
java.lang.Iterable<java.util.Map.Entry<K,V>> |
entries(K key)
Returns an Iterable over all key->value maplets in the map
whose key is equal to the one provided, as determined by the map's
definition of equality. |
V |
first(K key)
Returns the value associated with the first key that is equal to the one provided, as determined by the map's definition of equality. |
AnyMap<V,K> |
inverse()
Returns a map representing the inverse function of this map. |
boolean |
isEmpty()
Returns true iff the map is empty |
java.util.List<V> |
list(K key)
Returns a List of all values in the map which are mapped to by
the provided key, as determined by the map's definition of equality. |
boolean |
permitsDuplicateKeys()
Returns true if a key can map to more than one value |
V |
put(K key,
V val)
Ensures that the provided key binds to the provided value at least once; depending on the underlying implementation this may remove any existing key->value pairs where the key is equal to the one provided ( Map),
the key and value are both equal (MultiMap), or simply append
this key to all existing maplets regardless of their equality (ListMap). |
V |
putIfAbsent(K key,
V val)
Attempts to bind the provided key to the provided value. |
int |
remove(K key)
Removes all occurrences of the provided key from domain of the map, returning an integer representing the total number of items removed |
int |
remove(K key,
V val)
Removes all occurrences of the provided key->value pair from the map, returning an integer representing the total number of items removed |
java.lang.Iterable<java.util.Map.Entry<K,V>> |
removeAndReturn(K key)
Removes all occurrences of the provided key from domain of the map, returning the entries removed |
java.lang.Iterable<java.util.Map.Entry<K,V>> |
removeAndReturn(K key,
V val)
Removes all occurrences of the provided key->value pair from the map, returning the entries removed |
V |
removeAndReturnFirst(K key)
Removes all occurrences of the provided key from domain of the map, returning the first such value removed, or null if none |
void |
shrink()
Attempts to make the map use less memory, if possible. |
int |
totalCount()
Return an integer representing the total number of maplets (i.e. |
int |
uniqueKeyCount()
Return an integer representing the number of unique keys in the domain of the map |
AnySet<V> |
values()
Returns a set representing the range of the map. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface org.jjoost.collections.AnyMap |
|---|
copy, entries, keys, values |
| Method Detail |
|---|
public int clear()
AnyMap
clear in interface AnyMap<K,V>public java.util.Iterator<java.util.Map.Entry<K,V>> clearAndReturn()
AnyMapIterator will accurately
represent the elements that are removed from the map; however the Iterator must be exhausted for
the clear operation to be guaranteed to have completed.
clearAndReturn in interface AnyMap<K,V>public AnyMap<V,K> inverse()
AnyMap
inverse in interface AnyMap<K,V>
public boolean add(K key,
V val)
AnyMapfalse if it could not be added, and true otherwise. In a
ListMap the return value will always be true; however in a MultiMap it will be
false, and hence the map remain unmodified, if a pair whose key and value are both equal to the ones provided (as
determined by the map's definitions of equality) is already present; and in a Map it will be false if a
pair whose key is equal to the one provided is already present. When the value of the pair is inequal to null, this is
equivalent to put(key, value) == null
add in interface AnyMap<K,V>key - key to insertval - value to insert
true if the map was modified, false otherwise
public V put(K key,
V val)
AnyMapMap),
the key and value are both equal (MultiMap), or simply append
this key to all existing maplets regardless of their equality (ListMap).
If any pair is removed as a result of this action, the value of that pair is returned.
put in interface AnyMap<K,V>key - the keyval - the val
public V putIfAbsent(K key,
V val)
AnyMapMap will return
this value, whereas both MultiMap and ListMap will insert the
new pair and return null. If the key->value pair is present in the map then all maps
will return a value already associated with the key (in both Map and
MultiMap there will be precisely one such value)
putIfAbsent in interface AnyMap<K,V>key - the keyval - the val
public int remove(K key,
V val)
AnyMap
remove in interface AnyMap<K,V>key - the keyval - the val
public int remove(K key)
AnyMap
remove in interface AnyMap<K,V>key - remove
public java.lang.Iterable<java.util.Map.Entry<K,V>> removeAndReturn(K key,
V val)
AnyMap
removeAndReturn in interface AnyMap<K,V>key - key to removeval - value to remove
public java.lang.Iterable<java.util.Map.Entry<K,V>> removeAndReturn(K key)
AnyMap
removeAndReturn in interface AnyMap<K,V>key - key to remove
public V removeAndReturnFirst(K key)
AnyMap
removeAndReturnFirst in interface AnyMap<K,V>key - the key to remove
public void shrink()
AnyMap
shrink in interface AnyMap<K,V>
public boolean contains(K key,
V val)
AnyReadMap
contains in interface AnyReadMap<K,V>key - the keyval - the val
public boolean contains(K key)
AnyReadMap
contains in interface AnyReadMap<K,V>key - find
public int count(K key,
V val)
AnyReadMap
count in interface AnyReadMap<K,V>key - the keyval - the val
public int count(K key)
AnyReadMap
count in interface AnyReadMap<K,V>key - the key
public java.lang.Iterable<java.util.Map.Entry<K,V>> entries(K key)
AnyReadMapIterable over all key->value maplets in the map
whose key is equal to the one provided, as determined by the map's
definition of equality.
entries in interface AnyReadMap<K,V>key - find
public V first(K key)
AnyReadMapnull if no matching key
is found.
first in interface AnyReadMap<K,V>key - the key
public boolean isEmpty()
AnyReadMap
isEmpty in interface AnyReadMap<K,V>public java.util.List<V> list(K key)
AnyReadMapList of all values in the map which are mapped to by
the provided key, as determined by the map's definition of equality. This list
should be constructed "eagerly" and should be a consistent snapshot of
the values valid at some point between the method being called and it returning.
list in interface AnyReadMap<K,V>key - the key
public boolean permitsDuplicateKeys()
AnyReadMap
permitsDuplicateKeys in interface AnyReadMap<K,V>public int totalCount()
AnyReadMap
totalCount in interface AnyReadMap<K,V>public int uniqueKeyCount()
AnyReadMap
uniqueKeyCount in interface AnyReadMap<K,V>public AnySet<V> values()
AnyMap
values in interface AnyMap<K,V>values in interface AnyReadMap<K,V>
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||