|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
A bimap whose values are maintained in groups associated with the keys. Efficiently maps a key (Object) to a group (Group) of one or more values (Object), and a value to a set (Set) of one or more keys. The identity (equals(), hashCode()) of a bimap is that of its key-to-value map store, plus an instanceof test for Bimap. Unlike a Map, all views are immutable unless otherwise noted by a given implementation.
Todo: Refactor so that entrySet() works according to Map, null keys and values are allowed, and groups can be a Set or List.
Nested Class Summary |
Nested classes inherited from class java.util.Map |
java.util.Map.Entry |
Method Summary | |
void |
addAll(java.util.Collection keys,
int index,
java.util.Collection values)
Adds all the values to the groups associated with all the keys. |
void |
addAll(java.util.Map map)
Adds all the entries in the map to this one. |
void |
addAllKeys(java.util.Collection keys,
int index,
java.lang.Object value)
Adds a value to the groups associated with all the keys. |
void |
addAllValues(java.lang.Object key,
int index,
java.util.Collection values)
Adds all the values to the group associated with a key. |
void |
addValue(java.lang.Object key,
int index,
java.lang.Object value)
Adds a value to the group associated with a key. |
java.util.Set |
entrySet()
Gets an immutable view of the key-value entries (Map.Entry) in this bimap. |
java.lang.Object |
get(java.lang.Object key)
If the value group storage is a list, gets the value at the head of the list associated with the key. |
GroupBimap |
getGroupBimap()
Gets a singleton immutable view of this group bimap. |
Group |
getValues(java.lang.Object key)
Gets an immutable snapshot of the values (Object) associated with a key. |
java.lang.Object |
put(java.lang.Object key,
java.lang.Object value)
If the value group storage is a list, adds the value to the head of the list associated with the key. |
void |
putAll(java.util.Map t)
If the value group storage is a list, adds a map value to the head of the list associated with a key. |
java.lang.Object |
remove(java.lang.Object key)
Removes the values associated with a key. |
void |
removeAll(java.util.Collection keys,
java.util.Collection values)
Removes all the values from the groups associated with all the keys. |
void |
removeAllKeys(java.util.Collection keys,
java.lang.Object value)
Removes a value from the groups associated with all the keys. |
void |
removeAllValues(java.lang.Object key,
java.util.Collection values)
Removes all the values from the group associated with a key. |
void |
removeValue(java.lang.Object key,
java.lang.Object value)
Removes a value from the group associated with a key. |
java.util.Collection |
values()
If the value group storage is a list, gets the values at the head of the lists associated with the keys. |
Methods inherited from interface gumbo.util.Bimap |
getBimap, getKeys, keySet, removeAllKeys, removeAllValues, removeKey, removeValue, valueSet |
Methods inherited from interface java.util.Map |
clear, containsKey, containsValue, equals, hashCode, isEmpty, size |
Method Detail |
public void addValue(java.lang.Object key, int index, java.lang.Object value)
key
- Value group key. Never null.index
- List index. If not backed by a list, < 0. If backed
by a list, <= group size, with < 0 being the end of the list.value
- Value to be added. Ignored if null.
java.lang.UnsupportedOperationException
- If the group store is
not a List and index >= 0.public void addAllValues(java.lang.Object key, int index, java.util.Collection values)
public void addAllKeys(java.util.Collection keys, int index, java.lang.Object value)
public void addAll(java.util.Collection keys, int index, java.util.Collection values)
public void addAll(java.util.Map map)
public void removeValue(java.lang.Object key, java.lang.Object value)
key
- Value group key. Never null.value
- Value to be removed. Ignored if null or missing.public void removeAllValues(java.lang.Object key, java.util.Collection values)
public void removeAllKeys(java.util.Collection keys, java.lang.Object value)
public void removeAll(java.util.Collection keys, java.util.Collection values)
public Group getValues(java.lang.Object key)
public GroupBimap getGroupBimap()
public java.lang.Object put(java.lang.Object key, java.lang.Object value)
put
in interface java.util.Map
java.lang.UnsupportedOperationException
- Value group storage is
not a list. Use addValue().public void putAll(java.util.Map t)
putAll
in interface java.util.Map
java.lang.UnsupportedOperationException
- Value group storage is
not a list. Use addAll().public java.lang.Object get(java.lang.Object key)
get
in interface java.util.Map
java.lang.UnsupportedOperationException
- Value group storage is
not a list. Use getValues().public java.lang.Object remove(java.lang.Object key)
remove
in interface java.util.Map
public java.util.Collection values()
values
in interface Bimap
java.lang.UnsupportedOperationException
- Value group storage is
not a list. Use valueSet().public java.util.Set entrySet()
Bimap
entrySet
in interface Bimap
java.lang.UnsupportedOperationException
- Map entry values are private
groups. Public access is not allowed."
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |