12 Cell Neighbor List: Java Code public class Space2DCell.AtomIterator.UpNeighbor implements Atom.Iterator //Returns next atom from iterator public Atom next() { 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 return nextAtom; } //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 allDone(); return; } coordinate = (Coordinate)cell.first; //coordinate of first atom in cell (possibly null) } 321 654 b a
{}