| 
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
public interface Grid<E>
Grid provides an interface for a two-dimensional, grid-like
 environment containing arbitrary objects. 
 This interface is testable on the AP CS A and AB exams.
| Method Summary | |
|---|---|
 E | 
get(Location loc)
Returns the object at a given location in this grid.  | 
 java.util.ArrayList<Location> | 
getEmptyAdjacentLocations(Location loc)
Gets the valid empty locations adjacent to a given location in all eight compass directions (north, northeast, east, southeast, south, southwest, west, and northwest).  | 
 java.util.ArrayList<E> | 
getNeighbors(Location loc)
Gets the neighboring occupants in all eight compass directions (north, northeast, east, southeast, south, southwest, west, and northwest).  | 
 int | 
getNumCols()
Returns the number of columns in this grid.  | 
 int | 
getNumRows()
Returns the number of rows in this grid.  | 
 java.util.ArrayList<Location> | 
getOccupiedAdjacentLocations(Location loc)
Gets the valid occupied locations adjacent to a given location in all eight compass directions (north, northeast, east, southeast, south, southwest, west, and northwest).  | 
 java.util.ArrayList<Location> | 
getOccupiedLocations()
Gets the locations in this grid that contain objects.  | 
 java.util.ArrayList<Location> | 
getValidAdjacentLocations(Location loc)
Gets the valid locations adjacent to a given location in all eight compass directions (north, northeast, east, southeast, south, southwest, west, and northwest).  | 
 boolean | 
isValid(Location loc)
Checks whether a location is valid in this grid.  | 
 E | 
put(Location loc,
    E obj)
Puts an object at a given location in this grid.  | 
 E | 
remove(Location loc)
Removes the object at a given location from this grid.  | 
| Method Detail | 
|---|
int getNumRows()
int getNumCols()
boolean isValid(Location loc)
loc is not null
loc - the location to check
true if loc is valid in this grid,
 false otherwise
E put(Location loc,
      E obj)
loc is valid in this grid (2)
 obj is not null
loc - the location at which to put the objectobj - the new object to be added
loc (or null
 if the location was previously unoccupied)E remove(Location loc)
loc is valid in this grid
loc - the location of the object that is to be removed
null if the location
  is unoccupied)E get(Location loc)
loc is valid in this grid
loc - a location in this grid
loc (or null 
  if the location is unoccupied)java.util.ArrayList<Location> getOccupiedLocations()
java.util.ArrayList<Location> getValidAdjacentLocations(Location loc)
loc is valid in this grid
loc - a location in this grid
loc
 in this gridjava.util.ArrayList<Location> getEmptyAdjacentLocations(Location loc)
loc is valid in this grid
loc - a location in this grid
loc in this gridjava.util.ArrayList<Location> getOccupiedAdjacentLocations(Location loc)
loc is valid in this grid
loc - a location in this grid
loc in this gridjava.util.ArrayList<E> getNeighbors(Location loc)
loc is valid in this grid
loc - a location in this grid
loc in this grid
  | 
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||