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

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

public class ActiveObjectArrayList<E extends ActiveObject>
extends ActiveObjectList<E>

Replicated active object list based on array implementation
Supports fast element retrieval by its index (the get(int) operation runs in constant time).
The add operation runs in amortized constant time, that is, adding n elements requires O(n) time.

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

Constructor Summary
ActiveObjectArrayList()
          Constructs an empty list with an initial capacity of ten.
 
Method Summary
 void _add(E activeObject)
          This method should not be called by user
Call add_EONAME() method of class containing embedded object with name EONAME
 boolean _remove(E activeObject)
          This method should not be called by user
Call remove_EONAME() method of class containing embedded object with name EONAME
 boolean contains(java.lang.Object activeObject)
          Returns true if this replicated active object contains the specified element.
 E get(int index)
          Returns the active object element at the specified position in this replicated active object.
 boolean isEmpty()
          Returns true if this replicated active object contains no elements.
 java.util.Iterator<E> iterator()
          Returns an iterator over the replicated active object.
 E random()
          Randomly returns one active object from this collection
(uses uniform distribution from the Engine)
This method runs in constant time
 int size()
          Returns the number of elements in this replicated active object.
 java.lang.String toString()
           
 
Methods inherited from class com.xj.anylogic.engine.ActiveObjectCollection
average, average, count, max, max, min, min, restoreOwner, sum, sum
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ActiveObjectArrayList

public ActiveObjectArrayList()
Constructs an empty list with an initial capacity of ten.

Method Detail

_add

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

Specified by:
_add in class ActiveObjectCollection<E extends ActiveObject>

_remove

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

Specified by:
_remove in class ActiveObjectCollection<E extends ActiveObject>

get

public E get(int index)
Description copied from class: ActiveObjectList
Returns the active object element at the specified position in this replicated active object.
The position index is the number of list element in the insertion order (i.e. the order in which active object were added to this replicated active object list). Thus, index of an element decreases when preceding elements are removed.

Specified by:
get in class ActiveObjectList<E extends ActiveObject>
Parameters:
index - index of the element to return
Returns:
the element at the specified position in this list

contains

public boolean contains(java.lang.Object activeObject)
Description copied from class: ActiveObjectCollection
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)).

Specified by:
contains in class ActiveObjectCollection<E extends ActiveObject>
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

isEmpty

public boolean isEmpty()
Description copied from class: ActiveObjectCollection
Returns true if this replicated active object contains no elements.

Specified by:
isEmpty in class ActiveObjectCollection<E extends ActiveObject>
Returns:
true if this replicated active object contains no elements

iterator

public java.util.Iterator<E> iterator()
Description copied from class: ActiveObjectList
Returns an iterator over the replicated active object.
This iterator guarantees the insertion order of elements (i.e. the order in which active object were added to this replicated active object list).
Note, that returned iterator doesn't support remove operation

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

size

public int size()
Description copied from class: ActiveObjectCollection
Returns the number of elements in this replicated active object.
If this collection contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.

Specified by:
size in class ActiveObjectCollection<E extends ActiveObject>
Returns:
the number of 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 constant time

Overrides:
random in class ActiveObjectCollection<E extends ActiveObject>
Returns:
the active object randomly chosen from this collection
(uses uniform distribution from the Engine)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


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