Class KeySetIteratorBasedMap<K,V>

  extended by java.util.AbstractMap<K,V>
      extended by net.sf.molae.pipe.genimpl.KeySetBasedMap<K,V>
          extended by net.sf.molae.pipe.genimpl.KeySetIteratorBasedMap<K,V>
All Implemented Interfaces:
Direct Known Subclasses:

public abstract class KeySetIteratorBasedMap<K,V>
extends KeySetBasedMap<K,V>

Base class for maps that are defined by a key set iterator and a mapping that defines the key for each value. An AbstactSet based skeleton implementaion of the keySet is provided. Inheriting classes must implement getKeySetIterator() and get(Object). To implement a modifiable map, the programmer must additionally override this class's put(Object,Object) method (which otherwise throws an UnsupportedOperationException), and the iterator returned by keySet().iterator() must additionally implement its remove method.

Nested Class Summary
protected  class KeySetIteratorBasedMap.KeySet
          Provides a standard implementation of the key set of the map.
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
Constructor Summary
Method Summary
protected abstract  Iterator<K> getKeySetIterator()
          Returns the iterator of the key set.
 Set<K> keySet()
          Returns a set view of the keys contained in this map.
 int size()
          Returns the number of mappings in this map.
Methods inherited from class net.sf.molae.pipe.genimpl.KeySetBasedMap
clear, containsKey, entrySet, get, remove
Methods inherited from class java.util.AbstractMap
clone, containsValue, equals, hashCode, isEmpty, put, putAll, toString, values
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait

Constructor Detail


public KeySetIteratorBasedMap()
Method Detail


protected abstract Iterator<K> getKeySetIterator()
Returns the iterator of the key set.

the iterator of the key set


public int size()
Returns the number of mappings in this map. This implementation uses the key set iterator to count the elements in this set.

Specified by:
size in interface Map<K,V>
size in class KeySetBasedMap<K,V>
the number of mappings in this map


public Set<K> keySet()
Returns a set view of the keys contained in this map. This implementation returns an instance of the inner class KeySet.

Specified by:
keySet in interface Map<K,V>
Specified by:
keySet in class KeySetBasedMap<K,V>
a set view of the keys contained in this map.