SiteIterator
, java.io.Serializable
RectangularLatticeNbrIteratorAdjacent
, RectangularLatticeNbrIteratorSquare
public abstract class RectangularLatticeNbrIterator extends java.lang.Object implements SiteIterator, java.io.Serializable
Iterator can be configured to yield the up- and/or down-neighbors of the site. The definition of "up" and "down" neighbors is made by the subclass, within the restriction that if site B is an up-neighbor of site A, then A will be a down-neighbor of site B. Note that because of the way periodic boundaries are treated, a transitive relation is not guaranteed, meaning that (B upNbr of A) and (C upNbr of B) does not imply (C upNbr of A).
The central site is not included among the iterates (not a self-neighbor).
Modifier and Type | Field | Description |
---|---|---|
protected int |
cursor |
|
protected int |
D |
|
protected boolean |
doDown |
|
protected boolean |
doUp |
|
protected boolean[] |
isPeriodic |
|
protected RectangularLattice |
lattice |
|
protected boolean |
needNeighborUpdate |
|
protected int |
neighborCount |
|
protected int[] |
neighbors |
Constructor | Description |
---|---|
RectangularLatticeNbrIterator(int D) |
Constructs iterator that needs to be configured before use.
|
Modifier and Type | Method | Description |
---|---|---|
int |
D() |
|
IteratorDirective.Direction |
getDirection() |
Gets the direction (up or down list) of the neighbors given by the iterator.
|
RectangularLattice |
getLattice() |
Returns the lattice from which the iterates are given.
|
boolean |
hasNext() |
Indicates whether the iterator has another site.
|
java.lang.Object |
next() |
Returns the next site in the iteration sequence, or null
if hasNext is false.
|
int[] |
nextIndex() |
Returns the index of the next iterate while advancing the
iterator.
|
java.lang.Object |
peek() |
Returns the next iterate without advancing the iterator.
|
void |
reset() |
Resets the iterator to loop through its iterates again.
|
void |
setDirection(IteratorDirective.Direction direction) |
Sets the iterator to return only up-list neighbors or down-list neighbors.
|
void |
setLattice(FiniteLattice lattice) |
Sets the lattice from which the iterates are given.
|
void |
setPeriodicity(boolean[] periodicity) |
|
void |
setSite(int[] index) |
Identifies the site whose neighbors will be given on iteration.
|
int |
size() |
The number of iterates returned by this iterator in its current state.
|
void |
unset() |
Puts iterator in a state in which hasNext() returns false.
|
protected abstract void |
updateNeighborList() |
protected final int D
protected boolean needNeighborUpdate
protected int[] neighbors
protected RectangularLattice lattice
protected int cursor
protected int neighborCount
protected boolean doUp
protected boolean doDown
protected final boolean[] isPeriodic
public RectangularLatticeNbrIterator(int D)
protected abstract void updateNeighborList()
public final int D()
public void setSite(int[] index)
index
- the coordinate of the central sitepublic final boolean hasNext()
hasNext
in interface SiteIterator
public void reset()
reset
in interface SiteIterator
public void unset()
unset
in interface SiteIterator
public int[] nextIndex()
nextIndex
in interface SiteIterator
public java.lang.Object next()
next
in interface SiteIterator
public java.lang.Object peek()
peek
in interface SiteIterator
public int size()
size
in interface SiteIterator
public IteratorDirective.Direction getDirection()
public void setDirection(IteratorDirective.Direction direction)
public RectangularLattice getLattice()
public void setLattice(FiniteLattice lattice)
setLattice
in interface SiteIterator
public void setPeriodicity(boolean[] periodicity)