etomica.atom.iterator
Class ApiInterArrayList

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

public class ApiInterArrayList
extends Object
implements AtomLeafsetIterator, Serializable

Returns all pairs formed from two different untabbed lists of atoms. Incorrect behavior will result if both lists refer to the same instance.

See Also:
Serialized Form

Constructor Summary
ApiInterArrayList()
          Construct iterator with an empty lists.
ApiInterArrayList(IAtomList outerList, IAtomList innerList)
          Constructs iterator to return pairs from the given lists.
 
Method Summary
 IAtomList getInnerList()
          Returns the inner list used to generate the pairs.
 IAtomList getOuterList()
          Returns the outer list used to generate the pairs.
 int nBody()
          Returns 2, indicating that this is a pair iterator
 IAtomList next()
          Returns the next iterate pair.
 void reset()
          Sets iterator in condition to begin iteration.
 void setInnerList(IAtomList newList)
          Sets the list that will be used to generate the pairs.
 void setOuterList(IAtomList newList)
          Sets the list that will be used to generate the pairs.
 int size()
          Returns the number of iterates, which is list.size*(list.size-1)/2
 void unset()
          Sets iterator such that hasNext is false.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ApiInterArrayList

public ApiInterArrayList()
Construct iterator with an empty lists. No iterates will be given until non-empty lists are specified via setList.


ApiInterArrayList

public ApiInterArrayList(IAtomList outerList,
                         IAtomList innerList)
Constructs iterator to return pairs from the given lists. Requires reset() before first use.

Throws:
IllegalArgumentException - if both lists refer to the same instance
Method Detail

reset

public void reset()
Sets iterator in condition to begin iteration.

Specified by:
reset in interface AtomsetIterator
Throws:
IllegalStateException - if outer and inner lists have been set to the same instance

unset

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

Specified by:
unset in interface AtomsetIterator

next

public IAtomList next()
Returns the next iterate pair. Returns null if there are no more iterates.

Specified by:
next in interface AtomLeafsetIterator

size

public int size()
Returns the number of iterates, which is list.size*(list.size-1)/2

Specified by:
size in interface AtomsetIterator

nBody

public int nBody()
Returns 2, indicating that this is a pair iterator

Specified by:
nBody in interface AtomsetIterator
Returns:

setOuterList

public void setOuterList(IAtomList newList)
Sets the list that will be used to generate the pairs. Must call reset() before beginning iteration.

Parameters:
atomList - the new atom list for iteration

setInnerList

public void setInnerList(IAtomList newList)
Sets the list that will be used to generate the pairs. Must call reset() before beginning iteration.

Parameters:
atomList - the new atom list for iteration

getOuterList

public IAtomList getOuterList()
Returns the outer list used to generate the pairs.


getInnerList

public IAtomList getInnerList()
Returns the inner list used to generate the pairs.