Class SingleOccupancyCellAccessor<T>

java.lang.Object
repast.simphony.space.grid.SingleOccupancyCellAccessor<T>
All Implemented Interfaces:
CellAccessor<T,Map<GridPoint,Object>>

public class SingleOccupancyCellAccessor<T> extends Object implements CellAccessor<T,Map<GridPoint,Object>>
Coordinate accessor for a space where each location holds a single object.
Author:
Nick Collier
  • Constructor Details

    • SingleOccupancyCellAccessor

      public SingleOccupancyCellAccessor()
  • Method Details

    • get

      public T get(Map<GridPoint,Object> locationMap, GridPoint location)
      Gets the item at the specified location in the map.
      Specified by:
      get in interface CellAccessor<T,Map<GridPoint,Object>>
      Parameters:
      locationMap - the location map to put the object in
      location - the location in the map
      Returns:
      the item at the specified location
    • getAll

      public Iterable<T> getAll(Map<GridPoint,Object> locationMap, GridPoint location)
      Gets all the items at the specified location in the map.
      Specified by:
      getAll in interface CellAccessor<T,Map<GridPoint,Object>>
      Parameters:
      locationMap - the location map to retrieve from
      location - the location in the map
      Returns:
      an iterator over all the items at the specified location
    • getRandom

      public T getRandom(Map<GridPoint,Object> locationMap, GridPoint location)
      Gets a random item from those at the specified location in the map.
      Specified by:
      getRandom in interface CellAccessor<T,Map<GridPoint,Object>>
      Parameters:
      locationMap - the location map to retrieve from
      location - the location in the map
      Returns:
      a random item at the specified location
    • 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.
      Specified by:
      put in interface CellAccessor<T,Map<GridPoint,Object>>
      Parameters:
      obj - the object to put at the location
      locationMap - the location map to put the object in
      location - the location in the map
      Returns:
      true if the put was successful, otherwise false.
    • allowsMultiOccupancy

      public boolean allowsMultiOccupancy()
      Always returns false.
      Specified by:
      allowsMultiOccupancy in interface CellAccessor<T,Map<GridPoint,Object>>
      Returns:
      true if this cell accessor allows multi occupancy, otherwise false.
    • remove

      public void remove(T obj, Map<GridPoint,Object> locationMap, GridPoint location)
      Removes the specified object from the location in the map.
      Specified by:
      remove in interface CellAccessor<T,Map<GridPoint,Object>>
      Parameters:
      obj - the object to remove
      locationMap - the location map to remove the object from
      location - the location in the map