Cell Neighbor List: Java Code
public class Space2DCell.AtomIterator.UpNeighbor implements Atom.Iterator
//Returns next atom from iterator
nextAtom = (Atom)coordinate.parent(); //atom to be returned
coordinate = coordinate.nextNeighbor; //prepare for next atom
if(coordinate == null) {advanceCell();} //cell is empty; get atom from next cell
//Advances up through list of cells until an occupied one is found
private void advanceCell() {
while(coordinate == null) { //loop while on an empty cell
cell = cell.nextSite(); //next cell
if(cell == null) { //no more cells
coordinate = (Coordinate)cell.first; //coordinate of first atom in cell (possibly null)