com.xj.anylogic.engine
Class ActiveObjectCollection<E extends ActiveObject>

java.lang.Object
  extended by com.xj.anylogic.engine.ActiveObjectCollection<E>
Type Parameters:
E - Active Object type
All Implemented Interfaces:
com.xj.anylogic.engine.internal.Child, java.io.Serializable, java.lang.Iterable<E>
Direct Known Subclasses:
ActiveObjectList

public abstract class ActiveObjectCollection<E extends ActiveObject>
extends java.lang.Object
implements java.lang.Iterable<E>, java.io.Serializable, com.xj.anylogic.engine.internal.Child

Replicated active object collection interface

Author:
XJ Technologies Company Ltd. www.anylogic.com
See Also:
ActiveObjectList, Serialized Form

Constructor Summary
ActiveObjectCollection()
           
 
Method Summary
abstract  void _add(E activeObject)
          This method should not be called by user
Call add_EONAME() method of class containing embedded object with name EONAME
abstract  boolean _remove(E activeObject)
          This method should not be called by user
Call remove_EONAME() method of class containing embedded object with name EONAME
 double average(java.lang.String fieldName)
          Returns the average of (numeric) field values for all active objects in this collection
 double average(java.lang.String fieldName, java.lang.String triggerFieldName)
          Returns the average of (numeric) field values for all active objects in this collection which have true value of a boolean field with name triggerFieldName (if specified)
abstract  boolean contains(java.lang.Object activeObject)
          Returns true if this replicated active object contains the specified element.
 int count(java.lang.String triggerFieldName)
          Returns the number of active objects in this collection which have true value of a boolean field with name triggerFieldName
abstract  boolean isEmpty()
          Returns true if this replicated active object contains no elements.
abstract  java.util.Iterator<E> iterator()
          Returns an iterator over the replicated active object.
 double max(java.lang.String fieldName)
          Returns the maximum of (numeric) field values for all active objects in this collection
 double max(java.lang.String fieldName, java.lang.String triggerFieldName)
          Returns the maximum of (numeric) field values for all active objects in this collection which have true value of a boolean field with name triggerFieldName (if specified)
 double min(java.util.Collection<? extends ActiveObject> activeObjects, java.lang.String fieldName, java.lang.String triggerFieldName)
          Returns the minimum of (numeric) field values for all active objects in this collection which have true value of a boolean field with name triggerFieldName (if specified)
 double min(java.lang.String fieldName)
          Returns the minimum of (numeric) field values for all active objects in this collection
 E random()
          Randomly returns one active object from this collection
(uses uniform distribution from the Engine)
This method runs in linear time
 void restoreOwner(java.lang.Object owner)
          This method normally should not be called by user
This method restores owner of this object
The method is used in snapshot saving/loading
abstract  int size()
          Returns the number of elements in this replicated active object.
 double sum(java.lang.String fieldName)
          Returns the sum of (numeric) field values for all active objects in this collection
 double sum(java.lang.String fieldName, java.lang.String triggerFieldName)
          Returns the sum of (numeric) field values for all active objects in this collection which have true value of a boolean field with name triggerFieldName (if specified)
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ActiveObjectCollection

public ActiveObjectCollection()
Method Detail

_add

public abstract void _add(E activeObject)
This method should not be called by user
Call add_EONAME() method of class containing embedded object with name EONAME


_remove

public abstract boolean _remove(E activeObject)
This method should not be called by user
Call remove_EONAME() method of class containing embedded object with name EONAME


size

public abstract int size()
Returns the number of elements in this replicated active object.
If this collection contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.

Returns:
the number of elements in this replicated active object

isEmpty

public abstract boolean isEmpty()
Returns true if this replicated active object contains no elements.

Returns:
true if this replicated active object contains no elements

contains

public abstract boolean contains(java.lang.Object activeObject)
Returns true if this replicated active object contains the specified element. More formally, returns true if and only if this collection contains at least one element e such that (o==null ? e==null : o.equals(e)).

Parameters:
activeObject - element whose presence in this replicated active object is to be tested
Returns:
true if this replicated active object contains the specified element

iterator

public abstract java.util.Iterator<E> iterator()
Returns an iterator over the replicated active object.
There are no guarantees concerning the order in which the elements are returned (unless this collection is an instance of some class that provides a guarantee).

Specified by:
iterator in interface java.lang.Iterable<E extends ActiveObject>
Returns:
an Iterator over the elements in this replicated active object

random

public E random()
Randomly returns one active object from this collection
(uses uniform distribution from the Engine)
This method runs in linear time

Returns:
the active object randomly chosen from this collection
(uses uniform distribution from the Engine)

sum

public double sum(java.lang.String fieldName,
                  java.lang.String triggerFieldName)
Returns the sum of (numeric) field values for all active objects in this collection which have true value of a boolean field with name triggerFieldName (if specified)

Parameters:
fieldName - the name of the field (case-sensitive) to be summed up
triggerFieldName - the name of the field (case-sensitive) to be checked for true when performing addition
May be null - in this case all the active objects are taken
Returns:
sum of field values for active objects

sum

public double sum(java.lang.String fieldName)
Returns the sum of (numeric) field values for all active objects in this collection

Parameters:
fieldName - the name of the field (case-sensitive) to be summed up
Returns:
the sum of the field values for all active objects

average

public double average(java.lang.String fieldName,
                      java.lang.String triggerFieldName)
Returns the average of (numeric) field values for all active objects in this collection which have true value of a boolean field with name triggerFieldName (if specified)

Parameters:
fieldName - the name of the field (case-sensitive) to be taken
triggerFieldName - the name of the field (case-sensitive) to be checked for true when performing calculation
May be null - in this case all the active objects are taken
Returns:
the average of the field values for active objects,
or 0 if there is no suitable active objects

average

public double average(java.lang.String fieldName)
Returns the average of (numeric) field values for all active objects in this collection

Parameters:
fieldName - the name of the field (case-sensitive) to be taken
Returns:
the average of the field values for all active objects,
or 0 if there is no active objects

min

public double min(java.util.Collection<? extends ActiveObject> activeObjects,
                  java.lang.String fieldName,
                  java.lang.String triggerFieldName)
Returns the minimum of (numeric) field values for all active objects in this collection which have true value of a boolean field with name triggerFieldName (if specified)

Parameters:
fieldName - the name of the field (case-sensitive) to be taken
triggerFieldName - the name of the field (case-sensitive) to be checked for true when performing minimum search
May be null - in this case all the active objects are taken
Returns:
the minimum of field values for active objects
Double.POSITIVE_INFINITY if there is no suitable active objects

min

public double min(java.lang.String fieldName)
Returns the minimum of (numeric) field values for all active objects in this collection

Parameters:
fieldName - the name of the field (case-sensitive) to be taken
Returns:
the minimum of the field values for all active objects
Double.NEGATIVE_INFINITY if there is no suitable active objects

max

public double max(java.lang.String fieldName,
                  java.lang.String triggerFieldName)
Returns the maximum of (numeric) field values for all active objects in this collection which have true value of a boolean field with name triggerFieldName (if specified)

Parameters:
fieldName - the name of the field (case-sensitive) to be taken
triggerFieldName - the name of the field (case-sensitive) to be checked for true when performing maximum search
May be null - in this case all the active objects are taken
Returns:
the maximum of field values for active objects
Double.NEGATIVE_INFINITY if there is no suitable active objects

max

public double max(java.lang.String fieldName)
Returns the maximum of (numeric) field values for all active objects in this collection

Parameters:
fieldName - the name of the field (case-sensitive) to be taken
Returns:
the maximum of the field values for all active objects
Double.NEGATIVE_INFINITY if there is no suitable active objects

count

public int count(java.lang.String triggerFieldName)
Returns the number of active objects in this collection which have true value of a boolean field with name triggerFieldName

Parameters:
triggerFieldName - the name of the field (case-sensitive) to be checked for true when performing calculation
May be null - in this case activeObjects.size() is returned (i.e. all the active objects are taken)
Returns:
the number of active objects which have true value of a boolean field with name triggerFieldName

restoreOwner

public final void restoreOwner(java.lang.Object owner)
This method normally should not be called by user
This method restores owner of this object
The method is used in snapshot saving/loading

Specified by:
restoreOwner in interface com.xj.anylogic.engine.internal.Child
Parameters:
owner - owner of this object, usually ActiveObject, Experiment or ShapeGroup


Copyright © 1991-2008 XJ Technlogies. All Rights Reserved.