etomica.atom.iterator
Class AtomIteratorSinglet

java.lang.Object
  extended by etomica.atom.iterator.AtomIteratorSinglet
All Implemented Interfaces:
AtomIterator, AtomIteratorAtomDependent, AtomLeafsetIterator, AtomsetIterator, Serializable

public final class AtomIteratorSinglet
extends Object
implements AtomIteratorAtomDependent, Serializable

Iterator that expires after returning a single atom, which is specified by a call to the setAtom method, or via the constructor. Subsequent calls to reset() and next() will return the specified atom, until another is specified via setAtom.

See Also:
Serialized Form

Field Summary
protected  AtomSetSinglet atomSetSinglet
           
 
Constructor Summary
AtomIteratorSinglet()
          Constructs iterator without defining atom.
AtomIteratorSinglet(IAtom a)
          Constructs iterator specifying that it return the given atom.
 
Method Summary
 IAtom getAtom()
           
 int nBody()
          Returns the number of atoms given in each iterate, i.e., the size of the atom array returned with each call to next().
 IAtomList next()
          Returns the next AtomSet iterate, or null if hasNext() is false.
 IAtom nextAtom()
          Returns the iterator's atom and unsets iterator.
 void reset()
          Resets iterator to a state where hasNext is true.
 void setAtom(IAtom a)
          Defines atom returned by iterator and leaves iterator unset.
 int size()
          returns 1 if atom is not null, 0 if atom is null.
 void unset()
          Sets iterator to a state where hasNext() returns false.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

atomSetSinglet

protected final AtomSetSinglet atomSetSinglet
Constructor Detail

AtomIteratorSinglet

public AtomIteratorSinglet()
Constructs iterator without defining atom. No atoms will be given by this iterator until a call to setAtom is performed.


AtomIteratorSinglet

public AtomIteratorSinglet(IAtom a)
Constructs iterator specifying that it return the given atom. Call to reset() must be performed before beginning iteration.

Parameters:
a - The atom that will be returned by this iterator upon reset.
Method Detail

setAtom

public void setAtom(IAtom a)
Defines atom returned by iterator and leaves iterator unset. Call to reset() must be performed before beginning iteration. If atom is null, hasNext will remain false on reset.

Specified by:
setAtom in interface AtomIteratorAtomDependent

getAtom

public IAtom getAtom()
Returns:
the atom given by this iterator as its single iterate

size

public int size()
returns 1 if atom is not null, 0 if atom is null.

Specified by:
size in interface AtomsetIterator

unset

public void unset()
Sets iterator to a state where hasNext() returns false.

Specified by:
unset in interface AtomsetIterator

reset

public void reset()
Resets iterator to a state where hasNext is true.

Specified by:
reset in interface AtomsetIterator

nextAtom

public IAtom nextAtom()
Returns the iterator's atom and unsets iterator.

Specified by:
nextAtom in interface AtomIterator

next

public IAtomList next()
Description copied from interface: AtomLeafsetIterator
Returns the next AtomSet iterate, or null if hasNext() is false.

Specified by:
next in interface AtomLeafsetIterator

nBody

public final int nBody()
Description copied from interface: AtomsetIterator
Returns the number of atoms given in each iterate, i.e., the size of the atom array returned with each call to next().

Specified by:
nBody in interface AtomsetIterator
Returns: