zinger.nibbles
Class Field.GridChange

java.lang.Object
  |
  +--zinger.nibbles.Field.GridChange
Enclosing class:
Field

public final class Field.GridChange
extends java.lang.Object

Represents a link in a queue of changes (deltas) to the grid. Since the chain is a singly linked list, old deltas are garbage collectable. Unfortunately there is no efficient way to make them recycleable. The benefit of this system is that the listeners are notified by the ticks of the timer. Whenever a listener becomes interested in the latest state of the grid, it simply validates itself by going through the remaining chain. Therefore, it needs to hold on to the last instance in the chain. Also, if a listener tunes in in the middle of the action while things are happening and needs to first get to the current state. This is done by simply constructing a parralel chain of deltas that covers the entire grid and is finally linked to the current last delta.

See Also:
Field.getLastChange(), Field.getAllChanges()

Field Summary
private  Field.GridChange next
           
 int x
           
 int y
           
 
Constructor Summary
  Field.GridChange(int x, int y)
           
(package private) Field.GridChange(int x, int y, Field.GridChange next)
          Special constructor used only by Field to link a parrallel chain of deltas to the main one.
 
Method Summary
 Field.GridChange getNext()
           
(package private)  SpaceOccupant getSpaceOccupant()
           
(package private)  Field.GridChange setNext(int x, int y)
          This is used only by Field to add another delta.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

x

public final int x

y

public final int y

next

private Field.GridChange next
Constructor Detail

Field.GridChange

public Field.GridChange(int x,
                        int y)

Field.GridChange

Field.GridChange(int x,
                 int y,
                 Field.GridChange next)
Special constructor used only by Field to link a parrallel chain of deltas to the main one.
Method Detail

getNext

public Field.GridChange getNext()

setNext

Field.GridChange setNext(int x,
                         int y)
This is used only by Field to add another delta.

getSpaceOccupant

SpaceOccupant getSpaceOccupant()