org.millscript.commons.util.iterator
Class AbstractMapIterator<K,V>

java.lang.Object
  extended by org.millscript.commons.util.iterator.AbstractMapIterator<K,V>
All Implemented Interfaces:
MapIterator<K,V>
Direct Known Subclasses:
AbstractEReferenceHashMap.HashMapIterator, AbstractITreeMap.ITreeMapNodeIterator, AbstractListIterator, EArrayMap.ArrayMapMapIterator, EBinaryTreeMap.NodeIterator, EHashMap.HashMapIterator, ELinkedHashMap.LinkedHashMapIterator, IArrayMap.ArrayMapMapIterator, IArraySet.ArraySetMapIterator, IHashMap.HashMapIterator, IJavaUtilMap.JavaUtilMapIterator, ILinkedHashMap.LinkedHashMapIterator, IMapletArrayMap.MapletArrayMapIterator, ITwoArrayMap.TwoArrayMapIterator, NullMapIterator

public abstract class AbstractMapIterator<K,V>
extends java.lang.Object
implements MapIterator<K,V>

The class provides a skeletal implementation of the map iterator interface, to help with custom implementations.

All you need to do is provide an implmentation for the advance(), getKey(), getValue() and outOfBounds() methods.


Constructor Summary
AbstractMapIterator()
           
 
Method Summary
protected abstract  void advance()
          Advances this iterator to its next point.
 K currentKey()
          Returns the key for the current mapping in the iteration.
 Maplet<K,V> currentMaplet()
          Returns the current mapping in the iteration.
 V currentValue()
          Returns the value for the current mapping in the iteration.
protected abstract  K getKey()
          Returns the key for the current mapping in the iteration.
protected  Maplet<K,V> getMaplet()
          Returns the current mapping in the iteration.
protected abstract  V getValue()
          Returns the value for the current mapping in the iteration.
 K nextKey()
          Returns the key for the next mapping in the iteration.
 Maplet<K,V> nextMaplet()
          Returns the next mapping in the iteration.
 V nextValue()
          Returns the value for the next mapping in the iteration.
protected abstract  boolean outOfBounds()
          Returns true if this iterator is outside its bounds(before the first element or beyond the last) and false otherwise.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.millscript.commons.util.MapIterator
hasNext
 

Constructor Detail

AbstractMapIterator

public AbstractMapIterator()
Method Detail

advance

protected abstract void advance()
Advances this iterator to its next point. This method allows a common implementation of the next* methods, making it a little bit easier to implement the map iterator interface.


outOfBounds

protected abstract boolean outOfBounds()
Returns true if this iterator is outside its bounds(before the first element or beyond the last) and false otherwise.

Returns:
true if this iterator is outside its bounds and false otherwise

getKey

protected abstract K getKey()
Returns the key for the current mapping in the iteration. This method must be implemented by any concrete implementation and should not need to perform bounds checking.

Returns:
the key for the current mapping

getMaplet

protected Maplet<K,V> getMaplet()
Returns the current mapping in the iteration. This method must be implemented by any concrete implementation and should not need to perform bounds checking.

Returns:
the Maplet for the current mapping

getValue

protected abstract V getValue()
Returns the value for the current mapping in the iteration. This method must be implemented by any concrete implementation and should not need to perform bounds checking.

Returns:
the value for the current mapping

currentKey

public K currentKey()
Description copied from interface: MapIterator
Returns the key for the current mapping in the iteration.

Specified by:
currentKey in interface MapIterator<K,V>
Returns:
the key for the current mapping
See Also:
MapIterator.currentKey()

currentMaplet

public Maplet<K,V> currentMaplet()
Description copied from interface: MapIterator
Returns the current mapping in the iteration.

Specified by:
currentMaplet in interface MapIterator<K,V>
Returns:
the Maplet for the current mapping
See Also:
MapIterator.currentMaplet()

currentValue

public V currentValue()
Description copied from interface: MapIterator
Returns the value for the current mapping in the iteration.

Specified by:
currentValue in interface MapIterator<K,V>
Returns:
the value for the current mapping
See Also:
MapIterator.currentValue()

nextKey

public K nextKey()
Description copied from interface: MapIterator
Returns the key for the next mapping in the iteration.

Specified by:
nextKey in interface MapIterator<K,V>
Returns:
the key for the next mapping
See Also:
MapIterator.nextKey()

nextMaplet

public Maplet<K,V> nextMaplet()
Description copied from interface: MapIterator
Returns the next mapping in the iteration.

Specified by:
nextMaplet in interface MapIterator<K,V>
Returns:
the Maplet for the next mapping
See Also:
MapIterator.nextMaplet()

nextValue

public V nextValue()
Description copied from interface: MapIterator
Returns the value for the next mapping in the iteration.

Specified by:
nextValue in interface MapIterator<K,V>
Returns:
the value for the next mapping
See Also:
MapIterator.nextValue()


Copyright © 2005-2007 Open World Ltd. All Rights Reserved.