net.sf.molae.pipe.hash
Class ListBackedMap
java.lang.Object
|
+--java.util.AbstractMap
|
+--net.sf.molae.pipe.genimpl.KeySetBasedMap
|
+--net.sf.molae.pipe.hash.ListBackedMap
- All Implemented Interfaces:
- Map
- public final class ListBackedMap
- extends KeySetBasedMap
This class implements the map interface with a list implementation.
Prerequisite for this implementation is that
- A set of allowed keys must be defined.
- The hash keys within this set are unique
More formally: Be K the set of keys, then
∀ k1, k2 ∈ K
k1 ≠ k2 &there4
h(k1) ≠ h(k2)
For a good implementation the key set should not have big gaps and
the maximum key value should not be too big.
Null values are allowed.
Null keys are not allowed.
|
Method Summary |
Object |
get(Object key)
Returns the value to which this map maps the specified key. |
Set |
keySet()
Returns a set view of the keys contained in this map. |
static Map |
listAsMap(List base)
Returns a map that maps integers to the list entry at the
corresponding position in the base list. |
Object |
put(Object key,
Object value)
|
Object |
remove(Object key)
Removes the mapping for this key from this map if present (optional
operation). |
ListBackedMap
public ListBackedMap(List universe,
List values)
- Constructs a new ListBackedMap.
- Parameters:
universe - a collection containing all possible keysvalues - values of the map
ListBackedMap
public ListBackedMap(List universe)
- Constructs a new ListBackedMap.
- Parameters:
universe - a collection containing all possible keys- Throws:
NullPointerException - if the specified object is null
ListBackedMap
public ListBackedMap(Set universe)
- Constructs a new ListBackedMap.
- Parameters:
universe - a collection containing all possible keys- Throws:
NullPointerException - if the specified object is null
listAsMap
public static Map listAsMap(List base)
- Returns a map that maps integers to the list entry at the
corresponding position in the base list.
- Parameters:
base - the base list.- Returns:
- a map that maps integers to the list entry at the
corresponding position in the base list.
get
public Object get(Object key)
- Description copied from class:
KeySetBasedMap
- Returns the value to which this map maps the specified key.
Returns null if the map contains no mapping for this key.
- Overrides:
get in class KeySetBasedMap
- Following copied from class:
net.sf.molae.pipe.genimpl.KeySetBasedMap
- Parameters:
key - key whose associated value is to be returned.- Returns:
- the value to which this map maps the specified key.
- Throws:
ClassCastException - if the specified key is of an inappropriate
type for this map.NullPointerException - if the key is null and this map
does not not permit null keys.
put
public Object put(Object key,
Object value)
- Overrides:
put in class AbstractMap
remove
public Object remove(Object key)
- Description copied from class:
KeySetBasedMap
- Removes the mapping for this key from this map if present (optional
operation).
This implementation removes the specified key from the keySet().
- Overrides:
remove in class KeySetBasedMap
- Following copied from class:
net.sf.molae.pipe.genimpl.KeySetBasedMap
- Parameters:
key - key whose mapping is to be removed from the map.- Returns:
- previous value associated with specified key, or null
if there was no entry for key.
(A null return can also indicate that the map previously
associated null with the specified key,
if the implementation supports null values.)
- Throws:
UnsupportedOperationException - if the remove
operation is not supported by the key set.
keySet
public Set keySet()
- Description copied from class:
KeySetBasedMap
- Returns a set view of the keys contained in this map.
- Overrides:
keySet in class KeySetBasedMap
- Following copied from class:
net.sf.molae.pipe.genimpl.KeySetBasedMap
- Returns:
- a set view of the keys contained in this map.