## org.ascape.model.space
Class Array1D

    java.lang.Object
      org.ascape.model.space.CollectionSpace
          org.ascape.model.space.Discrete
              org.ascape.model.space.Array
                  org.ascape.model.space.ListBase
                      org.ascape.model.space.Array1D

All Implemented Interfaces:
  java.io.Serializable, java.lang.Cloneable, java.lang.Iterable, java.util.Collection, java.util.List, Space, RandomFunctions

    public class Array1D

extends ListBase

A one-dimensional, fixed-size, collection of agents providing services described for space.

Since:
  1.0
Version:
  3.0
Author:
  Miles Parker
See Also:
  Serialized Form

Nested Class Summary

Nested classes/interfaces inherited from class org.ascape.model.space.CollectionSpace
`CollectionSpace.ClosestDataPoint, CollectionSpace.ConditionalIterator, CollectionSpace.CSIterator, CollectionSpace.CSMutableIterator, CollectionSpace.ListMutableRandomIterator, CollectionSpace.ListRandomIterator, CollectionSpace.MutableSubIterator, CollectionSpace.SubIterator`

Field Summary

Fields inherited from class org.ascape.model.space.Array
`CACHE_RESULTS`

Fields inherited from class org.ascape.model.space.Discrete
`performanceWarning`

Fields inherited from class org.ascape.model.space.CollectionSpace
`collection, ESTIMATED_MAXIMUM_SIZE, extent, geometry`

Constructor Summary
`Array1D()` Constructs a one-dimensional immutable array.
`Array1D(CoordinateDiscrete extent)` Constructs a one-dimensional immutable array.

Method Summary
`void` `construct()` Contructs the basic structure.
`Location` `findRandom()` Returns a cell randomly selected from the lattice.
`Coordinate` `findRandomCoordinate()` Returns a coordinate randomly selected from the lattice's space.
`int` `findRandomIndex()` Returns a coordinate randomly selected from the lattice's space.
`java.util.List` `findWithinImpl(Coordinate origin, boolean includeSelf, double dist)` Returns cells that are near the provided cell.
`Location` `get(Coordinate coordinate)` Returns the object (agent) existing at the specified coordinate.
`java.lang.Object` `get(int xPosition)` Returns the cell existing at the specified coordinate position.
`Node[]` `getCells()` Returns all agents in the space as an array of cells (use this method to avoid coercion of memebers to Node.)
`Location[]` `getLocations()` Returns all agents in the space as an array.
`int` `getSize()` Returns the size, or number of cells, (the product of all extents) of this FixedList.
`void` `initialize()` Initializes the space, ensuring that the ordering used for random draws starts consistently.
`boolean` `isCoordinateSweepNeeded()` Is a coordinate location sweep needed for this space? Intended for internal purposes.
`boolean` `isDeleteSweepNeeded()` Is a delete sweep needed for this space? Intended for internal purposes.
`boolean` `isMutable()` Is the space mutable, that is, can it change its structure at runtime? Returns false for array 1D.
`java.util.Iterator` `iterator()` Returns an iterator across all agents in this context.
`void` `populate()` Populates the space with clones of the prototype agent.
`void` `randomizeCallingOrder()` Randomizes the lookup used to determine calling order for random order execution of rules.
`ResetableIterator` `safeIterator()` Returns a context iterator across all objects in this context.
`ResetableIterator` `safeIterator(int start, int limit)` Safe iterator.
`RandomIterator` `safeRandomIterator()` Returns a context iterator across all agents in random order.
`void` `setExtent(int size)` Sets the size of the array.
`void` `setGeometry(Geometry geometry)` Sets the geometry of this space.

Methods inherited from class org.ascape.model.space.ListBase
`add, add, add, add, addAll, calculateDistance, coordinateSweep, findCellAway, findCellToward, findFirstMatchInRank, findNearestMatchRank, findNearestMatchRank, findRandomMatchInRank, get, indexOf, lastIndexOf, listIterator, listIterator, remove, remove, remove, set, set, subList`

Methods inherited from class org.ascape.model.space.Array
`findNearest, findWithin, replace, swap`

Methods inherited from class org.ascape.model.space.Discrete

`bfsWithinIterator, calculateDistance, calculateNeighbors, findAvailable, findAvailable, findCellAwayBFS, findCellTowardBFS, findNearestAvailable, findNearestBFS, findNeighbors, findOccupants, findOccupants, findRandomAvailable, findRandomAvailable, findRandomAvailable, findRandomAvailableNeighbor, findRandomNeighbor, findRandomNeighbor, findRandomUnoccupiedCell, findRandomUnoccupiedCell, findWithinDefault, getCellsNearDefault, getDistance, getMaximumRank`

Methods inherited from class org.ascape.model.space.CollectionSpace

`add, addAll, calculateDistance, clear, clone, conditionalIterator, conditionalIterator, contains, containsAll, countWithin, createOrder, createSpatialConditional, deleteSweep, filter, find, findMaximum, findMaximum, findMaximumWithin, findMinimum, findMinimum, findMinimumWithin, findNearest, findRandom, findRandom, findRandom, findRandomWithin, getContext, getExtent, getGeometry, getRandom, hasWithin, isEmpty, isPeriodic, iteratorCount, iteratorToList, moveAway, moveToward, newLocation, newLocation, randomInRange, randomInRange, randomIs, randomizeOrder, randomToLimit, removeAll, retainAll, safeIterators, set, setContext, setExtent, setPeriodic, setRandom, setSize, size, toArray, toArray, toList, withinIterator`

Methods inherited from class java.lang.Object
`equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface java.util.List
`add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, removeAll, retainAll, size, toArray, toArray`

Constructor Detail

### Array1D

    public Array1D()

  Constructs a one-dimensional immutable array.

### Array1D

    public Array1D(CoordinateDiscrete extent)

  Constructs a one-dimensional immutable array.

  Parameters:
    `extent` - a coordinate describing the size of this space

Method Detail

### setGeometry

    public void setGeometry(Geometry geometry)

  Sets the geometry of this space. Must of course be a one-dimensional geometry.

  Overrides:
    `setGeometry` in class `ListBase`
  Parameters:
    `geometry` - the basic geometry of this space

### setExtent

    public void setExtent(int size)

  Sets the size of the array.

  Overrides:
    `setExtent` in class `CollectionSpace`
  Parameters:
    `size` - the size of this space

### construct

    public void construct()

  Contructs the basic structure. Instantiates the cells, but does not populate them. Geometry and extent should be set before calling this method.

  Specified by:
    `construct` in interface `Space`
  Overrides:
    `construct` in class `CollectionSpace`

### populate

    public void populate()

  Populates the space with clones of the prototype agent. Prototype agent should be set before calling this method. (By default, the prototpye agent is a Node.)

  Specified by:
    `populate` in interface `Space`
  Overrides:
    `populate` in class `ListBase`

### initialize

    public void initialize()

  Initializes the space, ensuring that the ordering used for random draws starts consistently.

  Specified by:
    `initialize` in interface `Space`
  Overrides:
    `initialize` in class `CollectionSpace`

### randomizeCallingOrder

    public void randomizeCallingOrder()

  Randomizes the lookup used to determine calling order for random order execution of rules.

### iterator

    public java.util.Iterator iterator()

  Description copied from class: `CollectionSpace`
  Returns an iterator across all agents in this context. Note that this is simply an iterator of the backing collections members. It will have different behavior than is typically desried when iterating behavior across a context*; so for instance, this method is not used by the internal rule mechanism. It should be perfectly adequete for tight iterations across agents when there are no additions or deletions during the iteration; for instance, when calcualting some value across a number of agents. *The iterator will not be aware of an agents deletion from the context after its creation; this is because the context caches these removals to improve performance. It may include agents that are added to the context after its creation, and this is typically not desirable behavior when touring a collection of current agents.

  Specified by:
    `iterator` in interface `java.lang.Iterable`
  Specified by:
    `iterator` in interface `java.util.Collection`
  Specified by:
    `iterator` in interface `java.util.List`
  Overrides:
    `iterator` in class `CollectionSpace`
  Returns:
    an iterator over the agents in context order

### safeIterator

    public ResetableIterator safeIterator()

  Description copied from class: `CollectionSpace`
  Returns a context iterator across all objects in this context. This iterator differs from a collection iterator in two fundamental ways. First, it handles deletions and adds differently. It does not include any objects that are added after the iterator has been created, and it correctly deals with the case where agents are removed from the context after the creation of the iterator. (As such deletions are marked for a later delete sweep, but not actually removed the iterator has to be aware of them.) Second, it allows these deletions to occur after an iteration has been created, without throwing a ConcurrentModificationExcpetion on a `next` (or similar) call. Such modifications (say during the execution of fission or death behaviors) during a particular behavior are expected. The important thing is that objects that have been removed from a context do not have rules executed upon them, and that new agents added to a context do not have behavior executed on them in the current iteration. This iterator ensures that.

  Specified by:
    `safeIterator` in interface `Space`
  Overrides:
    `safeIterator` in class `CollectionSpace`
  Returns:
    an iterator over the agents in context order

### safeIterator

    public ResetableIterator safeIterator(int start,
                                          int limit)

  Description copied from interface: `Space`
  Safe iterator.

  Specified by:
    `safeIterator` in interface `Space`
  Overrides:
    `safeIterator` in class `CollectionSpace`
  Parameters:
    `start` - the start
    `limit` - the limit
  Returns:
    the resetable iterator

### safeRandomIterator

    public RandomIterator safeRandomIterator()

  Description copied from class: `CollectionSpace`
  Returns a context iterator across all agents in random order. Other than its random order, it has identical behavior to context iterator; see the important notes for that method.

  Specified by:
    `safeRandomIterator` in interface `Space`
  Overrides:
    `safeRandomIterator` in class `CollectionSpace`
  Returns:
    an iterator over the agents in context order

### getSize

    public int getSize()

  Returns the size, or number of cells, (the product of all extents) of this FixedList.

  Specified by:
    `getSize` in interface `Space`
  Overrides:
    `getSize` in class `Discrete`
  Returns:
    the size

### get

    public java.lang.Object get(int xPosition)

  Returns the cell existing at the specified coordinate position.

  Specified by:
    `get` in interface `java.util.List`
  Overrides:
    `get` in class `ListBase`
  Parameters:
    `xPosition` - the x position
  Returns:
    the object

### get

    public Location get(Coordinate coordinate)

  Returns the object (agent) existing at the specified coordinate.

  Specified by:
    `get` in interface `Space`
  Overrides:
    `get` in class `CollectionSpace`
  Parameters:
    `coordinate` - the coordinate
  Returns:
    the location

### findRandom

    public Location findRandom()

  Returns a cell randomly selected from the lattice.

  Specified by:
    `findRandom` in interface `Space`
  Overrides:
    `findRandom` in class `CollectionSpace`
  Returns:
    the location

### findRandomCoordinate

    public Coordinate findRandomCoordinate()

  Returns a coordinate randomly selected from the lattice's space.

  Specified by:
    `findRandomCoordinate` in interface `Space`
  Overrides:
    `findRandomCoordinate` in class `CollectionSpace`
  Returns:
    the coordinate

### findRandomIndex

    public int findRandomIndex()

  Returns a coordinate randomly selected from the lattice's space.

  Returns:
    the int

### findWithinImpl

    public java.util.List findWithinImpl(Coordinate origin,
                                         boolean includeSelf,
                                         double dist)

  Description copied from class: `ListBase`
  Returns cells that are near the provided cell. Need to fix for non-periodic space!

  Overrides:
    `findWithinImpl` in class `ListBase`
  Parameters:
    `origin` - the coordinate to find cells near
    `includeSelf` - should supplied agent be included in the return set
    `dist` - the distance to form centralCells to return cells
  Returns:
    the list

### isMutable

    public boolean isMutable()

  Is the space mutable, that is, can it change its structure at runtime? Returns false for array 1D.

  Specified by:
    `isMutable` in interface `Space`
  Overrides:
    `isMutable` in class `CollectionSpace`
  Returns:
    true, if is mutable

### isDeleteSweepNeeded

    public boolean isDeleteSweepNeeded()

  Is a delete sweep needed for this space? Intended for internal purposes.

  Overrides:
    `isDeleteSweepNeeded` in class `CollectionSpace`
  Returns:
    true, if is delete sweep needed

### isCoordinateSweepNeeded

    public boolean isCoordinateSweepNeeded()

  Is a coordinate location sweep needed for this space? Intended for internal purposes.

  Overrides:
    `isCoordinateSweepNeeded` in class `ListBase`
  Returns:
    true, if is coordinate sweep needed

### getCells

    public Node[] getCells()

  Returns all agents in the space as an array of cells (use this method to avoid coercion of memebers to Node.)

  Overrides:
    `getCells` in class `Discrete`
  Returns:
    the cells

### getLocations

    public Location[] getLocations()

  Returns all agents in the space as an array.

  Returns:
    the locations