public class ArrayListGrid
extends java.lang.Object
ArrayListGrid
class encapsulates two public inner
classes that extend the Grid
class to
model a two-dimensional grid by keeping track of their contents
in ArrayList
objects. The first public inner class,
ArrayListGrid.Bounded
, represents a bounded grid
using an ArrayList
, while the second public inner class,
ArrayListGrid.Unbounded
, represents an unbounded grid
using an ArrayList
.
Methods of both ArrayListGrid
classes have the
following time and space characteristics:
numObjects | O(1 ) | |
allObjects | O(n ) | |
isEmpty, objectAt | O(n ) | |
add | O(1 ) [amortized] | |
remove | O(n ) | |
space | O(n ) |
n
is the number of objects in the grid.
The ArrayListGrid
classes are based on the
College Board's UnboundedEnv
class, as allowed
by the GNU General Public License.
Direction
,
Location
,
GridObject
Modifier and Type | Class and Description |
---|---|
static class |
ArrayListGrid.ArrayListGridRep
Internal representation for an
ArrayList -based
implementation of a Grid class. |
static class |
ArrayListGrid.Bounded
An
ArrayListGrid.Bounded object is a rectangular,
bounded two-dimensional container data structure implemented as
an ArrayList of the objects it contains. |
static class |
ArrayListGrid.Unbounded
An
ArrayListGrid.Unounded object is an unbounded
two-dimensional container data structure implemented as
an ArrayList of the objects it contains. |