Package repast.simphony.space.grid
Class MultiOccupancyCellAccessor<T>
- java.lang.Object
-
- repast.simphony.space.grid.MultiOccupancyCellAccessor<T>
-
- All Implemented Interfaces:
CellAccessor<T,Map<GridPoint,Object>>
public class MultiOccupancyCellAccessor<T> extends Object implements CellAccessor<T,Map<GridPoint,Object>>
Coordinate accessor where a location can hold multiple individual objects. This uses a list to store the objects in each cell.- Author:
- Nick Collier
-
-
Constructor Summary
Constructors Constructor Description MultiOccupancyCellAccessor()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
allowsMultiOccupancy()
Always returns true.T
get(Map<GridPoint,Object> locationMap, GridPoint location)
Gets the item at the specified location in the map.Iterable<T>
getAll(Map<GridPoint,Object> locationMap, GridPoint location)
Gets all the items at the specified location in the map.T
getRandom(Map<GridPoint,Object> locationMap, GridPoint location)
Gets a random item from those at the specified location in the map.boolean
put(T obj, Map<GridPoint,Object> locationMap, GridPoint location)
Attempts to put the specified object at the specified location.void
remove(T obj, Map<GridPoint,Object> locationMap, GridPoint location)
Removes the specified object from the location in the map.
-
-
-
Method Detail
-
get
public T get(Map<GridPoint,Object> locationMap, GridPoint location)
Gets the item at the specified location in the map.
-
getAll
public Iterable<T> getAll(Map<GridPoint,Object> locationMap, GridPoint location)
Gets all the items at the specified location in the map.
-
getRandom
public T getRandom(Map<GridPoint,Object> locationMap, GridPoint location)
Gets a random item from those at the specified location in the map.
-
put
public boolean put(T obj, Map<GridPoint,Object> locationMap, GridPoint location)
Attempts to put the specified object at the specified location. Returns true if the put was successful. The semantics of the result will be determined by implementing classes.
-
allowsMultiOccupancy
public boolean allowsMultiOccupancy()
Always returns true.- Specified by:
allowsMultiOccupancy
in interfaceCellAccessor<T,Map<GridPoint,Object>>
- Returns:
- true if this cell accessor allows multi occupancy, otherwise false.
-
-