gumbo.util
Interface Bimap

All Superinterfaces:
java.util.Map
All Known Subinterfaces:
GroupBimap
All Known Implementing Classes:
AbstractBimap, AbstractGroupBimap

public interface Bimap
extends java.util.Map

A map that functions as an asymetric bi-directional map of non-null keys and values. Efficiently maps a key (Object) to one value (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. Unlike a Map, all views are immutable unless otherwise noted by a specific implementation.

Todo: Refactor so that entrySet() works according to Map, and null keys and values are allowed.

Version:
$Revision: 1.3 $
Author:
Jon Barrilleaux (jonb@jmbaai.com) of JMB and Associates Inc.

Nested Class Summary
 
Nested classes inherited from class java.util.Map
java.util.Map.Entry
 
Method Summary
 java.util.Set entrySet()
          Gets an immutable view of the key-value entries (Map.Entry) in this bimap.
 Bimap getBimap()
          Gets a singleton immutable view of this bimap.
 java.util.Set getKeys(java.lang.Object value)
          Gets an immutable snapshot of the keys associated with a value.
 java.util.Set keySet()
          Gets an immutable view of the keys (Object) in this bimap.
 void removeAllKeys(java.util.Collection keys)
          Removes all the keys and their associated values.
 void removeAllValues(java.util.Collection values)
          Removes all the values and their associated keys.
 void removeKey(java.lang.Object key)
          Removes the key and its associated value.
 void removeValue(java.lang.Object value)
          Removes the value and its associated keys.
 java.util.Collection values()
          Gets an immutable view of the values (Object) in this bimap.
 java.util.Set valueSet()
          Gets an immutable view of the values (Object) in this bimap as a set.
 
Methods inherited from interface java.util.Map
clear, containsKey, containsValue, equals, get, hashCode, isEmpty, put, putAll, remove, size
 

Method Detail

removeValue

public void removeValue(java.lang.Object value)
Removes the value and its associated keys.


removeAllValues

public void removeAllValues(java.util.Collection values)
Removes all the values and their associated keys.


removeKey

public void removeKey(java.lang.Object key)
Removes the key and its associated value. Similar in function to remove(Object).


removeAllKeys

public void removeAllKeys(java.util.Collection keys)
Removes all the keys and their associated values.


getKeys

public java.util.Set getKeys(java.lang.Object value)
Gets an immutable snapshot of the keys associated with a value.


valueSet

public java.util.Set valueSet()
Gets an immutable view of the values (Object) in this bimap as a set.


getBimap

public Bimap getBimap()
Gets a singleton immutable view of this bimap. To avoid unnecessary lazy builds, if possible, use other accessors instead of this view.

Returns:
The view. Never null.

entrySet

public java.util.Set entrySet()
Gets an immutable view of the key-value entries (Map.Entry) in this bimap.

Specified by:
entrySet in interface java.util.Map

keySet

public java.util.Set keySet()
Gets an immutable view of the keys (Object) in this bimap.

Specified by:
keySet in interface java.util.Map

values

public java.util.Collection values()
Gets an immutable view of the values (Object) in this bimap.

Specified by:
values in interface java.util.Map