net.sf.molae.pipe.genimpl
Class ListsBackedMap<K,V>

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by net.sf.molae.pipe.basic.AbstractMapWithSet<K,V>
          extended by net.sf.molae.pipe.genimpl.ListsBackedMap<K,V>
All Implemented Interfaces:
Map<K,V>

public final class ListsBackedMap<K,V>
extends AbstractMapWithSet<K,V>

This class implements the map interface using a list of keys and a list of values. Null values are allowed. Null keys are not allowed.

Since:
1.1

Nested Class Summary
 
Nested classes/interfaces inherited from class net.sf.molae.pipe.basic.AbstractMapWithSet
AbstractMapWithSet.EntrySet
 
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Constructor Summary
ListsBackedMap(List<K> keys)
          Constructs a new ListsBackedMap.
ListsBackedMap(List<K> keys, List<V> valueList)
          Constructs a new ListsBackedMap.
 
Method Summary
 void clear()
           
 boolean containsValue(Object value)
           
 V get(Object key)
           
protected  Iterator<Map.Entry<K,V>> getEntrySetIterator()
          Returns the iterator of the entry set.
 V put(K key, V value)
           
 V remove(Object key)
           
 void setTidy(boolean tidy)
          Specifies if removed map entries are set to null in the value list.
 
Methods inherited from class net.sf.molae.pipe.basic.AbstractMapWithSet
entrySet, keySet, size
 
Methods inherited from class java.util.AbstractMap
clone, containsKey, equals, hashCode, isEmpty, putAll, toString, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ListsBackedMap

public ListsBackedMap(List<K> keys,
                      List<V> valueList)
Constructs a new ListsBackedMap.

Parameters:
keys - keys of the map
valueList - values of the map
Throws:
NullPointerException - if any of the specified objects is null

ListsBackedMap

public ListsBackedMap(List<K> keys)
Constructs a new ListsBackedMap.

Parameters:
keys - keys of the map
Throws:
NullPointerException - if any of the specified objects is null
Method Detail

setTidy

public void setTidy(boolean tidy)
Specifies if removed map entries are set to null in the value list. If the value is changed from false to true the list is tidied up.


containsValue

public boolean containsValue(Object value)
Specified by:
containsValue in interface Map<K,V>
Overrides:
containsValue in class AbstractMap<K,V>

get

public V get(Object key)
Specified by:
get in interface Map<K,V>
Overrides:
get in class AbstractMap<K,V>

put

public V put(K key,
             V value)
Specified by:
put in interface Map<K,V>
Overrides:
put in class AbstractMap<K,V>

remove

public V remove(Object key)
Specified by:
remove in interface Map<K,V>
Overrides:
remove in class AbstractMap<K,V>

clear

public void clear()
Specified by:
clear in interface Map<K,V>
Overrides:
clear in class AbstractMap<K,V>

getEntrySetIterator

protected Iterator<Map.Entry<K,V>> getEntrySetIterator()
Description copied from class: AbstractMapWithSet
Returns the iterator of the entry set.

Specified by:
getEntrySetIterator in class AbstractMapWithSet<K,V>
Returns:
the iterator of the entry set.