rcf.core.util.groups
Class Pair.Iterator<A,B>

java.lang.Object
  extended by rcf.core.util.groups.Pair.Iterator<A,B>
Type Parameters:
A - The type of the first entry in each pair.
B - The type of the second entry in each pair.
All Implemented Interfaces:
rcf.core.util.collection.iterator.FixedUniIterator<Pair<A,B>>, rcf.core.util.collection.iterator.ImmutableFixedUniIterator<Pair<A,B>>, rcf.core.util.collection.position.FixedUniPosition<Pair<A,B>>, rcf.core.util.collection.position.ImmutableFixedUniPosition<Pair<A,B>>, rcf.core.util.Copyable, ImmutableSingletonInterface<Pair<A,B>>, SingletonInterface<Pair<A,B>>, ImmutableIterator<Pair<A,B>>, Iterator<Pair<A,B>>, ImmutablePosition<Pair<A,B>>, Position<Pair<A,B>>
Enclosing class:
Pair<A,B>

public static class Pair.Iterator<A,B>
extends Object
implements rcf.core.util.collection.iterator.FixedUniIterator<Pair<A,B>>

TODO: Javadoc Binds a pair of iterators, allowing them to be iterated in tandem.

Version:
$Revision: 1.37 $
Author:
Greg Gibeling

Field Summary
protected  Pair<A,B> curr
          TODO: Javadoc The current pair created from the wrapped iterators.
protected  Pair.Iterable<A,B> iterable
          TODO: Javadoc
protected  rcf.core.util.collection.iterator.FixedUniIterator<A> x
          TODO: Javadoc The first iterator which is being wrapped.
protected  rcf.core.util.collection.iterator.FixedUniIterator<B> y
          TODO: Javadoc The second iterator which is being wrapped.
 
Constructor Summary
Pair.Iterator(Pair.Iterable<A,B> _iterable, rcf.core.util.collection.iterator.FixedUniIterator<A> _a, rcf.core.util.collection.iterator.FixedUniIterator<B> _b)
          TODO: Javadoc Create an iterator pair from two iterator objects.
 
Method Summary
 rcf.core.util.collection.position.ImmutableFixedUniPosition<Pair<A,B>> asAbstract()
           
 Pair.Iterator<A,B> copy()
          TODO: Javadoc Return a new iterator which is currently at the same position as this iterator.
 boolean equals(Object o)
          Determine if the specified object is an instance of ImmutablPposition which represents the same position in the same abstract data structure, as this object.
 Pair<A,B> get()
          TODO: Javadoc Get the content element of this singleton.
 int hashCode()
           
 boolean isCompatible(ImmutablePosition<Pair<A,B>> p)
          Determine if this position is compatible to, i.e.
 boolean isPost()
           
 boolean isPre()
           
 boolean isRemoved()
          Determine if this position has been removed from the backing abstract data structure.
 boolean isSentinel()
          Determine if this position is a sentinel; i.e.
 boolean isValid()
          Determine if there has been a concurrent modification to the backing abstract data structure.
 Pair.Iterable<A,B> iterable()
          TODO: Javadoc
 Pair.Iterator<A,B> next(rcf.core.util.filter.Filter<Pair<A,B>> filter)
           
 Pair<A,B> remove()
          Remove this position, and the element associated with it from the backing abstract data structure, and return the element.
 Pair<A,B> set(Pair<A,B> a)
          TODO: Javadoc Set the content element of this singleton.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

curr

protected Pair<A,B> curr
TODO: Javadoc The current pair created from the wrapped iterators.


iterable

protected final Pair.Iterable<A,B> iterable
TODO: Javadoc


x

protected final rcf.core.util.collection.iterator.FixedUniIterator<A> x
TODO: Javadoc The first iterator which is being wrapped.


y

protected final rcf.core.util.collection.iterator.FixedUniIterator<B> y
TODO: Javadoc The second iterator which is being wrapped.

Constructor Detail

Pair.Iterator

public Pair.Iterator(Pair.Iterable<A,B> _iterable,
                     rcf.core.util.collection.iterator.FixedUniIterator<A> _a,
                     rcf.core.util.collection.iterator.FixedUniIterator<B> _b)
TODO: Javadoc Create an iterator pair from two iterator objects. TODO: Javadoc

Parameters:
_iterable -
_a - The A type iterator object.
_b - The B type iterator object.
Method Detail

asAbstract

public rcf.core.util.collection.position.ImmutableFixedUniPosition<Pair<A,B>> asAbstract()
Specified by:
asAbstract in interface rcf.core.util.collection.position.ImmutableFixedUniPosition<Pair<A,B>>

copy

public Pair.Iterator<A,B> copy()
Description copied from interface: ImmutableIterator
TODO: Javadoc Return a new iterator which is currently at the same position as this iterator. That is, this method will return an iterator i such that this.equals(i) && this.isCompatible(i) (notice that equals is symmetric but isCompatible is not). Note that a call to e.g. ImmutableFixedUniIterator.next(rcf.core.util.filter.Filter) on this must not affect i and vice-versa.

This method is extremely useful in conjunction with position based collections where iteration is expensive or positions have algorithmic importance or higher level semantics.

Specified by:
copy in interface rcf.core.util.collection.iterator.FixedUniIterator<Pair<A,B>>
Specified by:
copy in interface rcf.core.util.collection.iterator.ImmutableFixedUniIterator<Pair<A,B>>
Specified by:
copy in interface rcf.core.util.Copyable
Specified by:
copy in interface ImmutableIterator<Pair<A,B>>
Specified by:
copy in interface Iterator<Pair<A,B>>
Returns:
A new iterator i such that this.equals(i).

equals

public boolean equals(Object o)
Description copied from interface: ImmutablePosition
Determine if the specified object is an instance of ImmutablPposition which represents the same position in the same abstract data structure, as this object. Notice that for positions p and q, p.equals(q) implies p.isCompatible(q) && q.isCompatible(p).

Specified by:
equals in interface ImmutablePosition<Pair<A,B>>
Overrides:
equals in class Object
Parameters:
o - The object to compare this one to, for equality.
Returns:
true if this position and the one specified represent the same position, in the same abstract data structure.

get

public Pair<A,B> get()
Description copied from interface: ImmutableSingletonInterface
TODO: Javadoc Get the content element of this singleton.

Specified by:
get in interface ImmutableSingletonInterface<Pair<A,B>>
Returns:
The content element of this singleton.

hashCode

public int hashCode()
Overrides:
hashCode in class Object

isCompatible

public boolean isCompatible(ImmutablePosition<Pair<A,B>> p)
Description copied from interface: ImmutablePosition
Determine if this position is compatible to, i.e. indicates a position in the same abstract data structure as, the specfied position (should return true even for sentinel positions). This method should never throw exceptions (especially IncompatiblePositionException) as it is a test to avoid them.

Specified by:
isCompatible in interface ImmutablePosition<Pair<A,B>>
Parameters:
p - The position to determine if this one is compatible to.
Returns:
true indicates that this position and the specified one belong to the same abstract data structure.

isPost

public boolean isPost()
Specified by:
isPost in interface rcf.core.util.collection.position.ImmutableFixedUniPosition<Pair<A,B>>

isPre

public boolean isPre()
Specified by:
isPre in interface rcf.core.util.collection.position.ImmutableFixedUniPosition<Pair<A,B>>

isRemoved

public boolean isRemoved()
Description copied from interface: Position
Determine if this position has been removed from the backing abstract data structure.

Specified by:
isRemoved in interface Position<Pair<A,B>>
Returns:
true if this position has been removed from the backing abstract data structure.

isSentinel

public boolean isSentinel()
Description copied from interface: ImmutablePosition
Determine if this position is a sentinel; i.e. a position which does not contain an element in the backing abstract data structure, but which instead marks the start or end of an iteration or some other boundary condition.

Specified by:
isSentinel in interface ImmutablePosition<Pair<A,B>>
Returns:
true if this is a sentinel position.

isValid

public boolean isValid()
Description copied from interface: Position
Determine if there has been a concurrent modification to the backing abstract data structure. This method must return false in all cases where any method may throw a ConcurrentModificationException.

Specified by:
isValid in interface Position<Pair<A,B>>
Returns:
true indicates that this position is still valid (though it may have been removed, see Position.isRemoved()) in the backing abstract data structure. This also indicates that no method on this object will throw a ConcurrentModificationException at the time of this call.

iterable

public Pair.Iterable<A,B> iterable()
Description copied from interface: ImmutableIterator
TODO: Javadoc

Specified by:
iterable in interface rcf.core.util.collection.iterator.FixedUniIterator<Pair<A,B>>
Specified by:
iterable in interface rcf.core.util.collection.iterator.ImmutableFixedUniIterator<Pair<A,B>>
Specified by:
iterable in interface ImmutableIterator<Pair<A,B>>
Returns:

next

public Pair.Iterator<A,B> next(rcf.core.util.filter.Filter<Pair<A,B>> filter)
Specified by:
next in interface rcf.core.util.collection.iterator.FixedUniIterator<Pair<A,B>>
Specified by:
next in interface rcf.core.util.collection.iterator.ImmutableFixedUniIterator<Pair<A,B>>

remove

public Pair<A,B> remove()
Description copied from interface: Position
Remove this position, and the element associated with it from the backing abstract data structure, and return the element.

Specified by:
remove in interface Position<Pair<A,B>>
Returns:
The element at this position.
See Also:
ImmutableSingletonInterface.get()

set

public Pair<A,B> set(Pair<A,B> a)
Description copied from interface: SingletonInterface
TODO: Javadoc Set the content element of this singleton.

Specified by:
set in interface SingletonInterface<Pair<A,B>>
Specified by:
set in interface Position<Pair<A,B>>
Parameters:
a - The new content element of this singleton.
Returns:
The old content element of this singleton.

toString

public String toString()
Overrides:
toString in class Object