net.sf.molae.pipe.genimpl
Class KeySetIteratorBasedMap<K,V>
java.lang.Object
java.util.AbstractMap<K,V>
net.sf.molae.pipe.genimpl.KeySetBasedMap<K,V>
net.sf.molae.pipe.genimpl.KeySetIteratorBasedMap<K,V>
- All Implemented Interfaces:
- Map<K,V>
- Direct Known Subclasses:
- ResourceBundleAsMap
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 classes/interfaces inherited from interface java.util.Map |
Map.Entry<K,V> |
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. |
KeySetIteratorBasedMap
public KeySetIteratorBasedMap()
getKeySetIterator
protected abstract Iterator<K> 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.
- Specified by:
size
in interface Map<K,V>
- Overrides:
size
in class KeySetBasedMap<K,V>
- Returns:
- the number of mappings in this map
keySet
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>
- Returns:
- a set view of the keys contained in this map.