Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.ascape.model.space
Class CollectionSpace

    java.lang.Object
      org.ascape.model.space.CollectionSpace

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

Direct Known Subclasses:
  Continuous1D, Continuous2D, Discrete, Singleton, SubCollection

    public class CollectionSpace

extends java.lang.Object
implements Space, java.lang.Cloneable, java.io.Serializable

The Class CollectionSpace.

See Also:
  Serialized Form

Nested Class Summary
`class` | `CollectionSpace.ClosestDataPoint` The Class ClosestDataPoint.
`static class` | `CollectionSpace.ConditionalIterator` The Class ConditionalIterator.
`protected class` | `CollectionSpace.CSIterator` The Class CSIterator.
`protected class` | `CollectionSpace.CSMutableIterator` The Class CSMutableIterator.
`protected class` | `CollectionSpace.ListMutableRandomIterator` The Class ListMutableRandomIterator.
`protected class` | `CollectionSpace.ListRandomIterator` The Class ListRandomIterator.
`protected class` | `CollectionSpace.MutableSubIterator` The Class MutableSubIterator.
`protected class` | `CollectionSpace.SubIterator` The Class SubIterator.

Field Summary
`protected java.util.Collection` | `collection` The backing collection.
`static int` | `ESTIMATED_MAXIMUM_SIZE` The estimated maximum size a typical collection will be.
`protected Coordinate` | `extent` The extent (furthest valid point) of the context.
`protected Geometry` | `geometry` The basic geometric structure of this collection.

Constructor Summary
`CollectionSpace()` Instantiates a new collection space.

Method Summary
`boolean` | `add(java.lang.Object a)` Adds the supplied object (agent) to this collection.
`boolean` | `add(java.lang.Object o, boolean isParent)` Adds the supplied object to this collection.
`boolean` | `addAll(java.util.Collection c)` Adds all of the agent in the specified collection to the end of the context.
`double` | `calculateDistance(Coordinate origin, Coordinate target)` Returns the shortest distance between one Location and another.
`double` | `calculateDistance(Location origin, Location target)` Returns the shortest distance between one agent and another.
`void` | `clear()` Removes all agents from the context.
`java.lang.Object` | `clone()` Overides the clone method to do a deep clone of member state so that such state will not be shared between scapes.
`java.util.Iterator` | `conditionalIterator(Conditional condition)` Conditional iterator.
`static java.util.Iterator` | `conditionalIterator(java.util.Iterator iter, Conditional condition)` Conditional iterator.
`void` | `construct()` Construct.
`boolean` | `contains(java.lang.Object o)` Returns true if the context collection contains the object (agent.)
`boolean` | `containsAll(java.util.Collection c)` Returns true if this collection contains all of agents in the specified collection.
`int` | `countWithin(Coordinate origin, Conditional condition, boolean includeSelf, double distance)` Returns the number of agents within the specified distance of the agent that meet some condition.
`static int[]` | `createOrder(int length)` Creates a new array of ints for use as indexes for an ordered iteration.
`protected Conditional` | `createSpatialConditional(Coordinate origin, Conditional condition, boolean includeSelf, double distance)` Creates the spatial conditional.
`void` | `deleteSweep()` Walks through each agent, deleting it if it has been marked for deletion.
`static java.util.List` | `filter(java.util.Collection list, Conditional condition)` Filter.
`java.util.List` | `find(Conditional condition)` Finds all locations with specified condition.
`Location` | `findMaximum(DataPoint point)` Returns the agent with the maximum value.
`Location` | `findMaximum(java.util.Iterator iter, DataPoint dataPoint)` Find the maximum cell of some data point.
`Location` | `findMaximumWithin(Coordinate coordinate, DataPoint dataPoint, Conditional condition, boolean includeSelf, double distance)` Find maximum within.
`Location` | `findMinimum(DataPoint point)` Returns the agent with the minimum value.
`Location` | `findMinimum(java.util.Iterator iter, DataPoint dataPoint)` Find minimum.
`Location` | `findMinimumWithin(Coordinate coordinate, DataPoint dataPoint, Conditional condition, boolean includeSelf, double distance)` Find minimum within.
`Location` | `findNearest(Coordinate origin, Conditional condition, boolean includeOrigin, double distance)` Finds the nearest agent that meets some condition.
`Location` | `findNearest(Location origin, Conditional condition, boolean includeOrigin, double distance)` Finds the nearest agent that meets some condition.
`Location` | `findRandom()` Returns an agent randomly selected from the collection.
`Location` | `findRandom(Conditional condition)` Returns an agent randomly that matches a condition.
`Location` | `findRandom(Location excludeLocation)` Returns a random unoccupied discrete location in the space given with the lattice.
`Location` | `findRandom(Location exclude, Conditional condition)` Returns an agent randomly that matches a condition, excluding the coordinate.
`Coordinate` | `findRandomCoordinate()` Returns a coordinate randomly selected from the collection's space.
`Location` | `findRandomWithin(Location origin, Conditional condition, boolean includeSelf, double distance)`
`java.util.List` | `findWithin(Coordinate origin, Conditional condition, boolean includeSelf, double distance)` Returns all agents within the specified distance of the agent.
`Location` | `get(Coordinate coordinate)` Returns the cell existing at the specified coordinate.
`SpaceContext` | `getContext()` Gets the context.
`Coordinate` | `getExtent()` Returns the extent of the context.
`Geometry` | `getGeometry()` Return the geometry of this context.
`java.util.Random` | `getRandom()`
`int` | `getSize()` Returns the size, or number of agents, of this space.
`boolean` | `hasWithin(Coordinate origin, Conditional condition, boolean includeSelf, double distance)` Returns if there are agents within the specified distance of the origin that meet some Condition.
`void` | `initialize()` Initialize.
`boolean` | `isDeleteSweepNeeded()` Is a delete sweep needed for this context? Intended for internal purposes.
`boolean` | `isEmpty()` Are there no agents in this context?.
`boolean` | `isMutable()` Is the context mutable, that is, can it change its structure at runtime? Returns true for this collection.
`boolean` | `isPeriodic()` Is the geometry periodic or aperiodic? (Do edges wrap to opposite side or not?).
`java.util.Iterator` | `iterator()` Returns an iterator across all agents in this context.
`static int` | `iteratorCount(java.util.Iterator iter)` Iterator count.
`static java.util.List` | `iteratorToList(java.util.Iterator iter)` Iterator to list.
`void` | `moveAway(Location origin, Coordinate target, double distance)` Moves an agent toward the specified agent.
`void` | `moveToward(Location origin, Coordinate target, double distance)` Moves an agent toward the specified agent.
`Location` | `newLocation()` Creates a new agent in this collection by cloning the prototype agent, adding it to the end of the vector, and initializing it.
`Location` | `newLocation(boolean randomLocation)` Creates a new agent in this collection by cloning the prototype agent, adding it to a random or arbitrary (last in this case) place in the collection, and initializing it.
`void` | `populate()` Populate.
`double` | `randomInRange(double low, double high)` Generate a double uniformly distributed across some range.
`int` | `randomInRange(int low, int high)` Generate an integer uniformly distributed across some range.
`boolean` | `randomIs()` Returns a random boolean value.
`static int[]` | `randomizeOrder(int[] order, java.util.Random random)` Randomizes order of the supplied int.
`int` | `randomToLimit(int limit)` Generate an integer uniformly distributed across 0...limit - 1.
`boolean` | `remove(java.lang.Object o)` Removes the supplied object (agent) from this collection.
`boolean` | `removeAll(java.util.Collection c)` Removes all of the agents contained in the collection.
`boolean` | `retainAll(java.util.Collection c)` Retains only the elements in the context that are in the specified collection.
`ResetableIterator` | `safeIterator()` Returns a context iterator across all objects in this context.
`ResetableIterator` | `safeIterator(int start, int limit)` Safe iterator.
`ResetableIterator[]` | `safeIterators(int count)` Returns multiple independently thread safe context iterators across all agents in this context.
`RandomIterator` | `safeRandomIterator()` Returns a context iterator across all agents in random order.
`void` | `set(Coordinate coordinate, Location agent)` Sets the agent at the specified coordinate to the supplied agent.
`void` | `setContext(SpaceContext context)` Sets the context.
`void` | `setExtent(Coordinate extent)` Sets the size of the context.
`void` | `setExtent(int size)` Sets the size of the collection.
`protected void` | `setGeometry(Geometry geometry)` Sets the geometry or basic structure of this context.
`void` | `setPeriodic(boolean periodic)` Sets the geometry to periodic or aperiodic.
`void` | `setRandom(java.util.Random random)`
`void` | `setSize(int internalSize)` Sets the size of the collection.
`int` | `size()` Returns the number of agents in the context.
`java.lang.Object[]` | `toArray()` Returns an array containing all of the elements in this collection in proper sequence.
`java.lang.Object[]` | `toArray(java.lang.Object[] a)` Returns an array containing the current agents in this context; the runtime type is specified by the passed array.
`java.util.List` | `toList()`
`java.util.Iterator` | `withinIterator(Coordinate origin, Conditional condition, boolean includeSelf, double distance)` Returns an iteration across all agents the specified distance from the origin.

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

Methods inherited from interface java.util.Collection
`equals, hashCode`

Field Detail

### ESTIMATED_MAXIMUM_SIZE

    public static int ESTIMATED_MAXIMUM_SIZE

  The estimated maximum size a typical collection will be.

### collection

    protected java.util.Collection collection

  The backing collection.

### geometry

    protected Geometry geometry

  The basic geometric structure of this collection.

### extent

    protected Coordinate extent

  The extent (furthest valid point) of the context. This parameter will make sense for some scapes, but not for others.

Constructor Detail

### CollectionSpace

    public CollectionSpace()

  Instantiates a new collection space.

Method Detail

### deleteSweep

    public void deleteSweep()

  Walks through each agent, deleting it if it has been marked for deletion.

### newLocation

    public Location newLocation()

  Creates a new agent in this collection by cloning the prototype agent, adding it to the end of the vector, and initializing it.

  Returns:
    the location

### newLocation

    public Location newLocation(boolean randomLocation)

  Creates a new agent in this collection by cloning the prototype agent, adding it to a random or arbitrary (last in this case) place in the collection, and initializing it.

  Specified by:
    `newLocation` in interface `Space`
  Parameters:
    `randomLocation` - should the agent be placed in a random location, or in an arbitrary location?
  Returns:
    the location

### isEmpty

    public boolean isEmpty()

  Are there no agents in this context?.

  Specified by:
    `isEmpty` in interface `java.util.Collection`
  Returns:
    true if the context is empty

### contains

    public boolean contains(java.lang.Object o)

  Returns true if the context collection contains the object (agent.)

  Specified by:
    `contains` in interface `java.util.Collection`
  Parameters:
    `o` - the agent to search for
  Returns:
    true if the context contains the agent

### toArray

    public java.lang.Object[] toArray()

  Returns an array containing all of the elements in this collection in proper sequence. Obeys the general contract of the `Collection.toArray` method.

  Specified by:
    `toArray` in interface `java.util.Collection`
  Returns:
    an array containing all of the elements in this collection in proper sequence.
  See Also:
    `Arrays.asList(java.lang.Object[])`

### toArray

    public java.lang.Object[] toArray(java.lang.Object[] a)

  Returns an array containing the current agents in this context; the runtime type is specified by the passed array.

  Specified by:
    `toArray` in interface `java.util.Collection`
  Parameters:
    `a` - the array to copy the agents to
  Returns:
    an array containing the agents
  Throws:
    `java.lang.ArrayStoreException` - if the runtime type of the specified array doesn't match all agents

### containsAll

    public boolean containsAll(java.util.Collection c)

  Returns true if this collection contains all of agents in the specified collection.

  Specified by:
    `containsAll` in interface `java.util.Collection`
  Parameters:
    `c` - collection of agents to be found in the context
  Returns:
    true if this context contains all of the agents in the collection

### addAll

    public boolean addAll(java.util.Collection c)

  Adds all of the agent in the specified collection to the end of the context. Assumes (but does not check) that all of the elements are instances of agent.

  Specified by:
    `addAll` in interface `java.util.Collection`
  Parameters:
    `c` - collection whose agents are to be added to the context
  Returns:
    true if the context had new agents added

### removeAll

    public boolean removeAll(java.util.Collection c)

  Removes all of the agents contained in the collection. No attempt is made to cache the removal; the agents are all removed at once.

  Specified by:
    `removeAll` in interface `java.util.Collection`
  Parameters:
    `c` - collection whose agents are to be added to the context
  Returns:
    true if the context had agents (but not neccessarily all?) removed

### retainAll

    public boolean retainAll(java.util.Collection c)

  Retains only the elements in the context that are in the specified collection.

  Specified by:
    `retainAll` in interface `java.util.Collection`
  Parameters:
    `c` - collection whose agents are to be retained in the context
  Returns:
    true if this context had agents removed

### clear

    public void clear()

  Removes all agents from the context.

  Specified by:
    `clear` in interface `java.util.Collection`

### add

    public boolean add(java.lang.Object a)

  Adds the supplied object (agent) to this collection.

  Specified by:
    `add` in interface `java.util.Collection`
  Parameters:
    `a` - the a
  Returns:
    true, if add

### add

    public boolean add(java.lang.Object o,
                       boolean isParent)

  Adds the supplied object to this collection. The object is assumed to be an agent, though that behavior may be loosened at some point.

  Specified by:
    `add` in interface `Space`
  Parameters:
    `o` - the agent to add
    `isParent` - should this context be made the parent context of the agent?
  Returns:
    true, if add
  Throws:
    `java.lang.ClassCastException` - if the object is not an instance of agent

### remove

    public boolean remove(java.lang.Object o)

  Removes the supplied object (agent) from this collection.

  Specified by:
    `remove` in interface `java.util.Collection`
  Parameters:
    `o` - the agent to be removed
  Returns:
    true if the agent was deleted, false otherwise

### iterator

    public java.util.Iterator iterator()

  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`
  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`
  Parameters:
    `start` - the start
    `limit` - the limit
  Returns:
    the resetable iterator

### isMutable

    public boolean isMutable()

  Is the context mutable, that is, can it change its structure at runtime? Returns true for this collection.

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

### safeIterators

    public ResetableIterator[] safeIterators(int count)

  Returns multiple independently thread safe context iterators across all agents in this context.

  Specified by:
    `safeIterators` in interface `Space`
  Parameters:
    `count` - the count
  Returns:
    an iterator over the agents in context order

### moveAway

    public void moveAway(Location origin,
                         Coordinate target,
                         double distance)

  Moves an agent toward the specified agent.

  Specified by:
    `moveAway` in interface `Space`
  Parameters:
    `origin` - the agent moving
    `target` - the agent's target
    `distance` - the distance to move

### moveToward

    public void moveToward(Location origin,
                           Coordinate target,
                           double distance)

  Moves an agent toward the specified agent. It is an error to call this method on collections (and discrete discrete scapes not composed of HostCells.

  Specified by:
    `moveToward` in interface `Space`
  Parameters:
    `origin` - the agent moving
    `target` - the agent's target
    `distance` - the distance to move

### calculateDistance

    public double calculateDistance(Location origin,
                                    Location target)

  Returns the shortest distance between one agent and another.

  Specified by:
    `calculateDistance` in interface `Space`
  Parameters:
    `origin` - the starting agent
    `target` - the ending agent
  Returns:
    the double

### calculateDistance

    public double calculateDistance(Coordinate origin,
                                    Coordinate target)

  Returns the shortest distance between one Location and another. Warning: this default method only returns a coordinate specific distance. It uses no information about the context context; for example wether it is a periodic (wrapping) space or not. Therefore, if you implement your own versions of CollectionSpace, ensure that you have properly implemented a version of this method. (All Ascape spaces properly overide this method.)

  Specified by:
    `calculateDistance` in interface `Space`
  Parameters:
    `origin` - one Location
    `target` - another Location
  Returns:
    the double

### find

    public java.util.List find(Conditional condition)

  Finds all locations with specified condition.

  Specified by:
    `find` in interface `Space`
  Parameters:
    `condition` - the condition to search locations for
  Returns:
    a list of found locations

### findMaximum

    public Location findMaximum(java.util.Iterator iter,
                                DataPoint dataPoint)

  Find the maximum cell of some data point. If multiple points have the same value, returns a random instance at that value.

  Parameters:
    `iter` - the iter
    `dataPoint` - the data point
  Returns:
    the location

### findNearest

    public Location findNearest(Coordinate origin,
                                Conditional condition,
                                boolean includeOrigin,
                                double distance)

  Finds the nearest agent that meets some condition. Spaces without coordinate meaing should override this method.

  Specified by:
    `findNearest` in interface `Space`
  Parameters:
    `origin` - the coordinate to find agents near
    `condition` - the condition that found agent must meet
    `includeOrigin` - if the origin should be included
    `distance` - the maximum distance around the origin to look
  Returns:
    the location

### findNearest

    public Location findNearest(Location origin,
                                Conditional condition,
                                boolean includeOrigin,
                                double distance)

  Finds the nearest agent that meets some condition. Spaces without coordinate meaing should override this method.

  Specified by:
    `findNearest` in interface `Space`
  Parameters:
    `origin` - the lcoation to find agents near
    `condition` - the condition that found agent must meet
    `includeOrigin` - if the origin should be included
    `distance` - the maximum distance around the origin to look
  Returns:
    the location

### findRandomCoordinate

    public Coordinate findRandomCoordinate()

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

  Specified by:
    `findRandomCoordinate` in interface `Space`
  Returns:
    the coordinate

### iteratorToList

    public static java.util.List iteratorToList(java.util.Iterator iter)

  Iterator to list.

  Parameters:
    `iter` - the iter
  Returns:
    the list

### iteratorCount

    public static int iteratorCount(java.util.Iterator iter)

  Iterator count.

  Parameters:
    `iter` - the iter
  Returns:
    the int

### findWithin

    public java.util.List findWithin(Coordinate origin,
                                     Conditional condition,
                                     boolean includeSelf,
                                     double distance)

  Returns all agents within the specified distance of the agent.

  Specified by:
    `findWithin` in interface `Space`
  Parameters:
    `origin` - the coordinate at the center of the search
    `includeSelf` - whether or not the starting agent should be included in the search
    `distance` - the distance agents must be within to be included
    `condition` - the condition
  Returns:
    the list

### countWithin

    public int countWithin(Coordinate origin,
                           Conditional condition,
                           boolean includeSelf,
                           double distance)

  Returns the number of agents within the specified distance of the agent that meet some condition.

  Specified by:
    `countWithin` in interface `Space`
  Parameters:
    `origin` - the coordinate at the center of the search
    `condition` - the condition the agent must meet to be included
    `distance` - the distance agents must be within to be included
    `includeSelf` - the include self
  Returns:
    the int

### hasWithin

    public boolean hasWithin(Coordinate origin,
                             Conditional condition,
                             boolean includeSelf,
                             double distance)

  Returns if there are agents within the specified distance of the origin that meet some Condition.

  Specified by:
    `hasWithin` in interface `Space`
  Parameters:
    `origin` - the coordinate at the center of the search
    `condition` - the condition the agent must meet to be included
    `distance` - the distance agents must be within to be included
    `includeSelf` - the include self
  Returns:
    true, if has within

### findMinimumWithin

    public Location findMinimumWithin(Coordinate coordinate,
                                      DataPoint dataPoint,
                                      Conditional condition,
                                      boolean includeSelf,
                                      double distance)

  Description copied from interface: `Space`
  Find minimum within.

  Specified by:
    `findMinimumWithin` in interface `Space`
  Parameters:
    `coordinate` - the coordinate
    `dataPoint` - the data point
    `condition` - the condition
    `includeSelf` - the include self
    `distance` - the distance
  Returns:
    the location

### findMaximumWithin

    public Location findMaximumWithin(Coordinate coordinate,
                                      DataPoint dataPoint,
                                      Conditional condition,
                                      boolean includeSelf,
                                      double distance)

  Description copied from interface: `Space`
  Find maximum within.

  Specified by:
    `findMaximumWithin` in interface `Space`
  Parameters:
    `coordinate` - the coordinate
    `dataPoint` - the data point
    `condition` - the condition
    `includeSelf` - the include self
    `distance` - the distance
  Returns:
    the location

### findMinimum

    public Location findMinimum(java.util.Iterator iter,
                                DataPoint dataPoint)

  Find minimum.

  Parameters:
    `iter` - the iter
    `dataPoint` - the data point
  Returns:
    the location

### safeIterator

    public ResetableIterator safeIterator()

  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`
  Returns:
    an iterator over the agents in context order

### safeRandomIterator

    public RandomIterator safeRandomIterator()

  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`
  Returns:
    an iterator over the agents in context order

### conditionalIterator

    public static java.util.Iterator conditionalIterator(java.util.Iterator iter,
                                                         Conditional condition)

  Conditional iterator.

  Parameters:
    `iter` - the iter
    `condition` - the condition
  Returns:
    the iterator

### conditionalIterator

    public java.util.Iterator conditionalIterator(Conditional condition)

  Description copied from interface: `Space`
  Conditional iterator.

  Specified by:
    `conditionalIterator` in interface `Space`
  Parameters:
    `condition` - the condition
  Returns:
    the iterator

### filter

    public static java.util.List filter(java.util.Collection list,
                                        Conditional condition)

  Filter.

  Parameters:
    `list` - the list
    `condition` - the condition
  Returns:
    the list

### withinIterator

    public java.util.Iterator withinIterator(Coordinate origin,
                                             Conditional condition,
                                             boolean includeSelf,
                                             double distance)

  Returns an iteration across all agents the specified distance from the origin.

  Specified by:
    `withinIterator` in interface `Space`
  Parameters:
    `origin` - the starting cell
    `includeSelf` - should the origin be included
    `distance` - the distance agents must be within to be included
    `condition` - the condition
  Returns:
    the iterator

### createSpatialConditional

    protected Conditional createSpatialConditional(Coordinate origin,
                                                   Conditional condition,
                                                   boolean includeSelf,
                                                   double distance)

  Creates the spatial conditional.

  Parameters:
    `origin` - the origin
    `condition` - the condition
    `includeSelf` - the include self
    `distance` - the distance
  Returns:
    the conditional

### findRandom

    public Location findRandom()

  Returns an agent randomly selected from the collection. If no agents exist, returns null.

  Specified by:
    `findRandom` in interface `Space`
  Returns:
    the location

### findRandom

    public Location findRandom(Location excludeLocation)

  Returns a random unoccupied discrete location in the space given with the lattice.

  Specified by:
    `findRandom` in interface `Space`
  Parameters:
    `excludeLocation` - a cell to exclude from get (typically origin)
  Returns:
    the location

### findRandom

    public Location findRandom(Conditional condition)

  Returns an agent randomly that matches a condition. Note: If there are no agents in the collection that meet the condition, the method returns null.

  Specified by:
    `findRandom` in interface `Space`
  Parameters:
    `condition` - the condition that must be matched
  Returns:
    the location

### findRandom

    public Location findRandom(Location exclude,
                               Conditional condition)

  Returns an agent randomly that matches a condition, excluding the coordinate. Note: If there are no agents in the collection that meet the condition, the method returns null.

  Specified by:
    `findRandom` in interface `Space`
  Parameters:
    `condition` - the condition that must be matched
  Returns:
    the location

### findRandomWithin

    public Location findRandomWithin(Location origin,
                                     Conditional condition,
                                     boolean includeSelf,
                                     double distance)

  Specified by:
    `findRandomWithin` in interface `Space`

### findMinimum

    public Location findMinimum(DataPoint point)

  Returns the agent with the minimum value.

  Specified by:
    `findMinimum` in interface `Space`
  Parameters:
    `point` - the data point to use to make the comparison for minimum
  Returns:
    the location

### findMaximum

    public Location findMaximum(DataPoint point)

  Returns the agent with the maximum value.

  Specified by:
    `findMaximum` in interface `Space`
  Parameters:
    `point` - the data point to use to make the comparison for maximum
  Returns:
    the location

### get

    public Location get(Coordinate coordinate)

  Returns the cell existing at the specified coordinate.

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

### set

    public void set(Coordinate coordinate,
                    Location agent)

  Sets the agent at the specified coordinate to the supplied agent.

  Specified by:
    `set` in interface `Space`
  Parameters:
    `coordinate` - the coordinate to add the agent at
    `agent` - the agent to add

### setExtent

    public void setExtent(int size)

  Sets the size of the collection. It is an error to set extent while a context is running.

  Parameters:
    `size` - the size of this context

### size

    public int size()

  Returns the number of agents in the context.

  Specified by:
    `size` in interface `java.util.Collection`
  Returns:
    the number of agents in the context

### getSize

    public int getSize()

  Returns the size, or number of agents, of this space.

  Specified by:
    `getSize` in interface `Space`
  Returns:
    the size

### getExtent

    public Coordinate getExtent()

  Returns the extent of the context. The extent can be thought of as the most extreme point in the context. For discrete context's this will simply be the furthest cell, so that for a 20x20 grid, the extent would be {20, 20}. For continuous spaces it will be the maximum boundary of the space. For lists, it will be the size of lists. Therefore, this method should net be confused with the context's "size". Note that context graphs will not have useful extents, but all other scapes do.

  Specified by:
    `getExtent` in interface `Space`
  Returns:
    the extent

### setExtent

    public void setExtent(Coordinate extent)

  Sets the size of the context. Note that context graphs will not have useful extents, but all other scapes do. It is an error to set extent while a context is running.

  Specified by:
    `setExtent` in interface `Space`
  Parameters:
    `extent` - a coordinate at the maximum extent

### isDeleteSweepNeeded

    public boolean isDeleteSweepNeeded()

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

  Returns:
    true, if is delete sweep needed

### setSize

    public void setSize(int internalSize)

  Sets the size of the collection. This method should be used to add or remove agents from the collection, caused by fissioning or the death of an agent.

  Specified by:
    `setSize` in interface `Space`
  Parameters:
    `internalSize` - the new size of the collection

### construct

    public void construct()

  Description copied from interface: `Space`
  Construct.

  Specified by:
    `construct` in interface `Space`

### populate

    public void populate()

  Description copied from interface: `Space`
  Populate.

  Specified by:
    `populate` in interface `Space`

### initialize

    public void initialize()

  Description copied from interface: `Space`
  Initialize.

  Specified by:
    `initialize` in interface `Space`

### randomInRange

    public int randomInRange(int low,
                             int high)

  Generate an integer uniformly distributed across some range.

  Specified by:
    `randomInRange` in interface `RandomFunctions`
  Parameters:
    `low` - the lowest number (inclusive) that the resulting int might be
    `high` - the hignest number (inclusive) that the resulting int might be
  Returns:
    uniformly distributed pseudorandom int

### randomInRange

    public double randomInRange(double low,
                                double high)

  Generate a double uniformly distributed across some range.

  Specified by:
    `randomInRange` in interface `RandomFunctions`
  Parameters:
    `low` - the lowest number (inclusive) that the resulting double might be
    `high` - the hignest number (exclusive) that the resulting double might be
  Returns:
    uniformly distributed pseudorandom double

### randomToLimit

    public int randomToLimit(int limit)

  Generate an integer uniformly distributed across 0...limit - 1.

  Specified by:
    `randomToLimit` in interface `RandomFunctions`
  Parameters:
    `limit` - the maximum limit (exclusive) of the resulting int
  Returns:
    uniformly distributed pseudorandom int

### randomIs

    public boolean randomIs()

  Returns a random boolean value.

  Specified by:
    `randomIs` in interface `RandomFunctions`
  Returns:
    true, if random is

### getContext

    public SpaceContext getContext()

  Description copied from interface: `Space`
  Gets the context.

  Specified by:
    `getContext` in interface `Space`
  Returns:
    the context

### setContext

    public void setContext(SpaceContext context)

  Description copied from interface: `Space`
  Sets the context.

  Specified by:
    `setContext` in interface `Space`
  Parameters:
    `context` - the new context

### getRandom

    public java.util.Random getRandom()

  Specified by:
    `getRandom` in interface `RandomFunctions`

### setRandom

    public void setRandom(java.util.Random random)

  Specified by:
    `setRandom` in interface `RandomFunctions`

### getGeometry

    public Geometry getGeometry()

  Return the geometry of this context.

  Specified by:
    `getGeometry` in interface `Space`
  Returns:
    the geometry

### setGeometry

    protected void setGeometry(Geometry geometry)

  Sets the geometry or basic structure of this context. This method should never be called directly, but is assigned by an implementing class or used with a factory method in Geometry.

  Parameters:
    `geometry` - the structure of this context

### isPeriodic

    public boolean isPeriodic()

  Is the geometry periodic or aperiodic? (Do edges wrap to opposite side or not?).

  Specified by:
    `isPeriodic` in interface `Space`
  Returns:
    true, if is periodic

### setPeriodic

    public void setPeriodic(boolean periodic)

  Sets the geometry to periodic or aperiodic.

  Specified by:
    `setPeriodic` in interface `Space`
  Parameters:
    `periodic` - true if periodic (wraps around at each edge), false is aperiodic

### clone

    public java.lang.Object clone()

  Overides the clone method to do a deep clone of member state so that such state will not be shared between scapes.

  Specified by:
    `clone` in interface `Space`
  Overrides:
    `clone` in class `java.lang.Object`
  Returns:
    the object

### createOrder

    public static int[] createOrder(int length)

  Creates a new array of ints for use as indexes for an ordered iteration. Initially sequential.

  Parameters:
    `length` - the length
  Returns:
    the int[]

### randomizeOrder

    public static int[] randomizeOrder(int[] order,
                                       java.util.Random random)

  Randomizes order of the supplied int.

  Parameters:
    `order` - the order
    `random` - the random
  Returns:
    the int[]

### toList

    public java.util.List toList()

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD