rcf.core.util.groups
Class Singleton.Iterator<A>

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

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

TODO: Javadoc Wrap a single iterator, create an iterator over singletons of elements.

Version:
$Revision: 1.29 $
Author:
Greg Gibeling

Field Summary
protected  Singleton<A> curr
          TODO: Javadoc The current singleton created from the wrapped iterator.
protected  Singleton.Iterable<A> iterable
          TODO: Javadoc
protected  rcf.core.util.collection.iterator.FixedUniIterator<A> x
          TODO: Javadoc The iterator which is being wrapped.
 
Constructor Summary
Singleton.Iterator(Singleton.Iterable<A> _iterable, rcf.core.util.collection.iterator.FixedUniIterator<A> _a)
          TODO: Javadoc Create an iterator of singletons from an iterable object.
 
Method Summary
 rcf.core.util.collection.position.ImmutableFixedUniPosition<Singleton<A>> asAbstract()
           
 Singleton.Iterator<A> 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.
 Singleton<A> get()
          TODO: Javadoc Get the content element of this singleton.
 int hashCode()
           
 boolean isCompatible(ImmutablePosition<Singleton<A>> 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.
 Singleton.Iterable<A> iterable()
          TODO: Javadoc
 Singleton.Iterator<A> next(rcf.core.util.filter.Filter<Singleton<A>> filter)
           
 Singleton<A> remove()
          Remove this position, and the element associated with it from the backing abstract data structure, and return the element.
 Singleton<A> set(Singleton<A> 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 Singleton<A> curr
TODO: Javadoc The current singleton created from the wrapped iterator.


iterable

protected final Singleton.Iterable<A> iterable
TODO: Javadoc


x

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

Constructor Detail

Singleton.Iterator

public Singleton.Iterator(Singleton.Iterable<A> _iterable,
                          rcf.core.util.collection.iterator.FixedUniIterator<A> _a)
TODO: Javadoc Create an iterator of singletons from an iterable object.

Parameters:
_a - The iterator object which is to be wrapped and iterated.
Method Detail

asAbstract

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

copy

public Singleton.Iterator<A> 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<Singleton<A>>
Specified by:
copy in interface rcf.core.util.collection.iterator.ImmutableFixedUniIterator<Singleton<A>>
Specified by:
copy in interface rcf.core.util.Copyable
Specified by:
copy in interface ImmutableIterator<Singleton<A>>
Specified by:
copy in interface Iterator<Singleton<A>>
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<Singleton<A>>
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 Singleton<A> get()
Description copied from interface: ImmutableSingletonInterface
TODO: Javadoc Get the content element of this singleton.

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

hashCode

public int hashCode()
Overrides:
hashCode in class Object

isCompatible

public boolean isCompatible(ImmutablePosition<Singleton<A>> 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<Singleton<A>>
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<Singleton<A>>

isPre

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

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<Singleton<A>>
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<Singleton<A>>
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<Singleton<A>>
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 Singleton.Iterable<A> iterable()
Description copied from interface: ImmutableIterator
TODO: Javadoc

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

next

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

remove

public Singleton<A> 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<Singleton<A>>
Returns:
The element at this position.
See Also:
ImmutableSingletonInterface.get()

set

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

Specified by:
set in interface SingletonInterface<Singleton<A>>
Specified by:
set in interface Position<Singleton<A>>
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