org.millscript.commons.util.map
Class AbstractEReferenceHashMap.HashMapIterator<K,V>

java.lang.Object
  extended by org.millscript.commons.util.iterator.AbstractMapIterator<K,V>
      extended by org.millscript.commons.util.map.AbstractEReferenceHashMap.HashMapIterator<K,V>
All Implemented Interfaces:
MapIterator<K,V>
Enclosing class:
AbstractEReferenceHashMap<K,V>

public static class AbstractEReferenceHashMap.HashMapIterator<K,V>
extends AbstractMapIterator<K,V>

This class implements a map iterator which iterates over an array of hash buckets, sharing the backing store with it's enclosing mutable map.

As expected, the iterator uses a copy-on-write contract with its enclosing class during the iteration. Simple updates will not cause a copy, but structural(i.e. inserts/removes) will cause a copy for the duration of the iteration.


Constructor Summary
AbstractEReferenceHashMap.HashMapIterator(AbstractEReferenceHashMap<K,V> map, boolean share)
          Constructs a new hash map iterator to iterate over the specified mutable hash map
 
Method Summary
protected  void advance()
          Advances this iterator to its next point.
protected  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  V getValue()
          Returns the value for the current mapping in the iteration.
 boolean hasNext()
          Returns true if there are more values available in this iteration and false otherwise.
protected  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 org.millscript.commons.util.iterator.AbstractMapIterator
currentKey, currentMaplet, currentValue, nextKey, nextMaplet, nextValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractEReferenceHashMap.HashMapIterator

public AbstractEReferenceHashMap.HashMapIterator(AbstractEReferenceHashMap<K,V> map,
                                                 boolean share)
Constructs a new hash map iterator to iterate over the specified mutable hash map

Parameters:
map - the mutable hash map to iterate over
share - if true the specified object array will be shared otherwise the array will be copied.
Method Detail

advance

protected void advance()
Description copied from class: AbstractMapIterator
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.

Specified by:
advance in class AbstractMapIterator<K,V>
See Also:
AbstractMapIterator.advance()

getKey

protected K getKey()
Description copied from class: AbstractMapIterator
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.

Specified by:
getKey in class AbstractMapIterator<K,V>
Returns:
the key for the current mapping
See Also:
AbstractMapIterator.getKey()

getMaplet

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

Overrides:
getMaplet in class AbstractMapIterator<K,V>
Returns:
the Maplet for the current mapping
See Also:
AbstractMapIterator.getMaplet()

getValue

protected V getValue()
Description copied from class: AbstractMapIterator
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.

Specified by:
getValue in class AbstractMapIterator<K,V>
Returns:
the value for the current mapping
See Also:
AbstractMapIterator.getValue()

hasNext

public boolean hasNext()
Description copied from interface: MapIterator
Returns true if there are more values available in this iteration and false otherwise.

Returns:
true if there are more values in this iteration and false otherwise
See Also:
MapIterator.hasNext()

outOfBounds

protected boolean outOfBounds()
Description copied from class: AbstractMapIterator
Returns true if this iterator is outside its bounds(before the first element or beyond the last) and false otherwise.

Specified by:
outOfBounds in class AbstractMapIterator<K,V>
Returns:
true if this iterator is outside its bounds and false otherwise
See Also:
AbstractMapIterator.outOfBounds()


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