etomica.atom.iterator
Class ApiIntergroup

java.lang.Object
  extended by etomica.atom.iterator.ApiIntergroup
All Implemented Interfaces:
AtomLeafsetIterator, AtomsetIterator, AtomsetIteratorBasisDependent, AtomsetIteratorTargetable

public class ApiIntergroup
extends Object
implements AtomsetIteratorBasisDependent

Iterator that returns pairs formed using two different basis atoms, so that the iterates are taken from two different groups.


Field Summary
protected  AtomIteratorBasis aiInner
           
protected  AtomIteratorBasis aiOuter
           
protected  MoleculeSetSinglet atomSetSinglet
           
protected  boolean needSetupIterators
           
protected  AtomPair pair
           
protected  IAtom targetAtom
           
 
Constructor Summary
ApiIntergroup()
          Default iterator is an ApiInnerFixed formed from two AtomIteratorBasis instances.
ApiIntergroup(AtomIteratorBasis outer, AtomIteratorBasis inner)
          Constructs a pair iterator that returns iterates from the given pairIterator, which is expected to contain two basis-dependent iterators.
 
Method Summary
 int basisSize()
          Returns 2, indicating that the setBasis method expects an array of two atoms.
 AtomIteratorBasis getInnerIterator()
          Accessor method for the inner-loop atom iterator.
 AtomIteratorBasis getOuterIterator()
          Accessor method for the outer-loop atom iterator.
 boolean haveTarget(IAtom target)
          Returns true if the iterator with its current basis would return an iterate for the given target.
 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 pair of atoms.
 void reset()
          Resets the iterator to loop through its iterates again.
 void setBasis(IMoleculeList basisAtoms)
          Specifies the basis, which identifies the atoms subject to iteration.
 void setTarget(IAtom newTargetAtom)
          Specifies a target atom, which should appear in all iterates.
protected  void setupIterators()
           
 int size()
          Returns the number of pairs given by this iterator.
 void unset()
          Sets the iterator such that hasNext is false.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pair

protected final AtomPair pair

aiInner

protected final AtomIteratorBasis aiInner

aiOuter

protected final AtomIteratorBasis aiOuter

targetAtom

protected IAtom targetAtom

needSetupIterators

protected boolean needSetupIterators

atomSetSinglet

protected final MoleculeSetSinglet atomSetSinglet
Constructor Detail

ApiIntergroup

public ApiIntergroup()
Default iterator is an ApiInnerFixed formed from two AtomIteratorBasis instances.


ApiIntergroup

public ApiIntergroup(AtomIteratorBasis outer,
                     AtomIteratorBasis inner)
Constructs a pair iterator that returns iterates from the given pairIterator, which is expected to contain two basis-dependent iterators.

Method Detail

getOuterIterator

public AtomIteratorBasis getOuterIterator()
Accessor method for the outer-loop atom iterator.

Returns:
the current outer-loop iterator

getInnerIterator

public AtomIteratorBasis getInnerIterator()
Accessor method for the inner-loop atom iterator.

Returns:
the current inner-loop iterator

unset

public void unset()
Sets the iterator such that hasNext is false.

Specified by:
unset in interface AtomsetIterator

size

public int size()
Returns the number of pairs given by this iterator. Not dependent on state of hasNext.

Specified by:
size in interface AtomsetIterator

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:

next

public IAtomList next()
Returns the next pair of atoms. The same AtomPair instance is returned every time, but the Atoms it holds are (of course) different for each iterate.

Specified by:
next in interface AtomLeafsetIterator

setTarget

public void setTarget(IAtom newTargetAtom)
Specifies a target atom, which should appear in all iterates. A null value removes any restriction on the iterates.

Specified by:
setTarget in interface AtomsetIteratorTargetable

haveTarget

public boolean haveTarget(IAtom target)
Description copied from interface: AtomsetIteratorBasisDependent
Returns true if the iterator with its current basis would return an iterate for the given target.

Specified by:
haveTarget in interface AtomsetIteratorBasisDependent

setupIterators

protected void setupIterators()

setBasis

public void setBasis(IMoleculeList basisAtoms)
Specifies the basis, which identifies the atoms subject to iteration. The given atomSet must be of length 2. The first atom in the set specifies the basis for the outer-loop iteration, and second atom specifies the basis for the inner-loop iteration. In each case, if the basis atom is not a leaf atom, its children will be the subject of iteration. If the basis atom is a leaf, it will itself be the iterate. If given atomset is null iterator will give no iterates until a proper basis is specified via another call to this method.

Specified by:
setBasis in interface AtomsetIteratorBasisDependent
Parameters:
basisAtoms - The basis atoms; a null basis will condition the iterator to give no iterates until a valid basis is specified via another call to this method.

reset

public void reset()
Description copied from interface: AtomsetIterator
Resets the iterator to loop through its iterates again.

Specified by:
reset in interface AtomsetIterator

basisSize

public int basisSize()
Returns 2, indicating that the setBasis method expects an array of two atoms.

Specified by:
basisSize in interface AtomsetIteratorBasisDependent
Returns:
the size of the basis for this iterator.