net.walend.grid
Interface Grid

All Superinterfaces:
java.util.Collection, HasState
All Known Subinterfaces:
Grid2D, MutableGrid, MutableGrid2D
All Known Implementing Classes:
AbstractArrayGrid2D, AbstractMapGrid2D, MutableArrayGrid2D, MutableMapGrid2D

public interface Grid
extends HasState, java.util.Collection

Grid is a Collection implanted in a multidimensional array.

Grid contains get, put and take methods that use Addresses to find the correct location in the Grid. A Grid also supplies Iterators and asList methods that cut a stripe accross the grid in a single dimension.

Grid is a superinterface, and should have subinterfaces that specify more information about the Grid's dimentions.

Grids typically use the sameGridAs method to determine if two Grids have the same contents, and reserve equals() and hashCode() for identity.

Generally, null values are OK in Grids.

Since:
20010927
Author:
David Walend dfw1@cornell.edu

Method Summary
 java.util.Iterator addressIterator()
          Returns an Iterator of all the addresses in the grid.
 Address addressOf(java.lang.Object object)
          Returns an Address in the Grid occupied by object.
 boolean containsAddress(Address address)
          Returns true if the address is on this Grid.
 boolean containsDimension(Dimension dimension)
          Returns true if dimension is used in this Grid.
 java.lang.Object get(Address address)
          Return the Object at address.
 net.walend.enum.Enum getDimensions()
          Returns the Dimensions enumerated type
 java.lang.Object getFillObject()
          Return the fill object for this grid.
 Address maxAddress()
          Return the address furthest from the origin for this grid.
 IndexedIterator stripeIterator(Address address, Dimension dimensionToScan)
          Returns an Iterator accross the stripe at Address, through dimensionToScan.
 
Methods inherited from interface net.walend.collection.HasState
getPrincipleInterface, sameStateAs
 
Methods inherited from interface java.util.Collection
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray
 

Method Detail

getFillObject

public java.lang.Object getFillObject()
Return the fill object for this grid.


containsDimension

public boolean containsDimension(Dimension dimension)
Returns true if dimension is used in this Grid.


getDimensions

public net.walend.enum.Enum getDimensions()
Returns the Dimensions enumerated type


maxAddress

public Address maxAddress()
Return the address furthest from the origin for this grid. You can use this address as the maximum value in for loops safly, provided your grid doesn't have arbitrary holes in it.


containsAddress

public boolean containsAddress(Address address)
Returns true if the address is on this Grid.


get

public java.lang.Object get(Address address)
                     throws OffGridException
Return the Object at address.

OffGridException

addressOf

public Address addressOf(java.lang.Object object)
                  throws ObjectNotOnGridException
Returns an Address in the Grid occupied by object.

ObjectNotOnGridException

stripeIterator

public IndexedIterator stripeIterator(Address address,
                                      Dimension dimensionToScan)
Returns an Iterator accross the stripe at Address, through dimensionToScan. This iterator is remarkably robust and will not throw ConcurrentModificationExceptions.


addressIterator

public java.util.Iterator addressIterator()
Returns an Iterator of all the addresses in the grid.



Copyright (c) 2001, 2002, David Walend