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 Singleton

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

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

    public class Singleton

extends CollectionSpace

A space with treates itself as its only member. This provides agents with a way to have single rules implemented upon them and to support views.

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.CollectionSpace
`collection, ESTIMATED_MAXIMUM_SIZE, extent, geometry`

Constructor Summary
`Singleton()` Construct a new Singleton.

Method Summary
`double` | `calculateDistance(Coordinate origin, Coordinate target)` Returns the shortest distance between one agent and another.
`void` | `construct()` Normally, create the basic strucutre of the space.
`Location` | `findRandom()` Returns an agent randomly selected from the collection.
`Coordinate` | `findRandomCoordinate()` Returns a coordinate randomly selected from the collection's space.
`Location[]` | `getLocations()` Returns all agents in the space as an array.
`int` | `getSize()` Returns the number of members of this space.
`boolean` | `isMutable()` Is the context mutable, that is, can it change its structure at runtime? Returns true for this collection.
`java.util.Iterator` | `iterator()` Returns an iterator across all agents in this context.
`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.
`void` | `populate()` Normally, populates the space with instances of its protoype agent.
`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(Coordinate extent)` Sets the size of the context.
`java.lang.String` | `toString()` Returns a string representing this space.

Methods inherited from class org.ascape.model.space.CollectionSpace
`add, add, addAll, calculateDistance, clear, clone, conditionalIterator, conditionalIterator, contains, containsAll, countWithin, createOrder, createSpatialConditional, deleteSweep, filter, find, findMaximum, findMaximum, findMaximumWithin, findMinimum, findMinimum, findMinimumWithin, findNearest, findNearest, findRandom, findRandom, findRandom, findRandomWithin, findWithin, get, getContext, getExtent, getGeometry, getRandom, hasWithin, initialize, isDeleteSweepNeeded, isEmpty, isPeriodic, iteratorCount, iteratorToList, newLocation, newLocation, randomInRange, randomInRange, randomIs, randomizeOrder, randomToLimit, remove, removeAll, retainAll, safeIterators, set, setContext, setExtent, setGeometry, setPeriodic, setRandom, setSize, size, toArray, toArray, toList, withinIterator`

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

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

Constructor Detail

### Singleton

    public Singleton()

  Construct a new Singleton.

Method Detail

### getSize

    public int getSize()

  Returns the number of members of this space.

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

### construct

    public void construct()

  Normally, create the basic strucutre of the space. Here, a noop, since the space member is the space itself.

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

### populate

    public void populate()

  Normally, populates the space with instances of its protoype agent. Here, a noop, since the space member is the space itself.

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

### 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`
  Overrides:
    `iterator` 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

### 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

### 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

### getLocations

    public Location[] getLocations()

  Returns all agents in the space as an array.

  Returns:
    the locations

### moveToward

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

  Moves an agent toward the specified agent.

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

### moveAway

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

  Moves an agent toward the specified agent.

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

### calculateDistance

    public double calculateDistance(Coordinate origin,
                                    Coordinate target)

  Returns the shortest distance between one agent and another. In this case, must be 0.

  Specified by:
    `calculateDistance` in interface `Space`
  Overrides:
    `calculateDistance` in class `CollectionSpace`
  Parameters:
    `origin` - the starting cell
    `target` - the ending cell
  Returns:
    the double

### toString

    public java.lang.String toString()

  Returns a string representing this space.

  Overrides:
    `toString` in class `java.lang.Object`
  Returns:
    the string

### findRandom

    public Location findRandom()

  Description copied from class: `CollectionSpace`
  Returns an agent randomly selected from the collection. If no agents exist, returns null.

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

### findRandomCoordinate

    public Coordinate findRandomCoordinate()

  Description copied from class: `CollectionSpace`
  Returns a coordinate randomly selected from the collection's space.

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

### setExtent

    public void setExtent(Coordinate extent)

  Description copied from class: `CollectionSpace`
  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`
  Overrides:
    `setExtent` in class `CollectionSpace`
  Parameters:
    `extent` - a coordinate at the maximum extent

### isMutable

    public final boolean isMutable()

  Description copied from class: `CollectionSpace`
  Is the context mutable, that is, can it change its structure at runtime? Returns true for this collection.

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

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