net.sf.molae.pipe.genimpl
Class KeySetIteratorBasedMap
java.lang.Object
|
+--java.util.AbstractMap
|
+--net.sf.molae.pipe.genimpl.KeySetBasedMap
|
+--net.sf.molae.pipe.genimpl.KeySetIteratorBasedMap
- All Implemented Interfaces:
- Map
- Direct Known Subclasses:
- ResourceBundleAsMap
- public abstract class KeySetIteratorBasedMap
- extends KeySetBasedMap
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.
|
Method Summary |
protected abstract Iterator |
getKeySetIterator()
Returns the iterator of the key set. |
Set |
keySet()
Returns a set view of the keys contained in this map. |
int |
size()
Returns the number of mappings in this map. |
KeySetIteratorBasedMap
public KeySetIteratorBasedMap()
getKeySetIterator
protected abstract Iterator getKeySetIterator()
- Returns the iterator of the key set.
- Returns:
- the iterator of the key set
size
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.
- Overrides:
size in class KeySetBasedMap
- Returns:
- the number of mappings in this map
keySet
public Set keySet()
- Returns a set view of the keys contained in this map.
This implementation returns an instance of the inner class
KeySet.
- Overrides:
keySet in class KeySetBasedMap
- Returns:
- a set view of the keys contained in this map.