Package com.anylogic.engine
- java.lang.Object
-
- com.anylogic.engine.AgentList<E>
-
- com.anylogic.engine.AgentLinkedHashSet<E>
- All Implemented Interfaces:
com.anylogic.engine.internal.Child
,java.io.Serializable
,java.lang.Iterable<E>
public class AgentLinkedHashSet<E extends Agent> extends AgentList<E>
Agent population collection based on
This collection offers constant time performance for the basic operations (add, remove, contains and size) and guarantees insertion-order during iteration
Note, that due to set-based implementation, element retrieval by its index (
LinkedHashSet
implementationThis collection offers constant time performance for the basic operations (add, remove, contains and size) and guarantees insertion-order during iteration
Note, that due to set-based implementation, element retrieval by its index (
get(int)
) is extremely slow when rapidly invoked it with random
index for large collections. In a similar manner, Agent.getIndex()
method of agents in this collection will be slow too.- Author:
- AnyLogic North America, LLC https://anylogic.com
- See Also:
- Serialized Form
AgentLinkedHashSet(Agent owner) |
|
Constructor | Description |
---|
void |
_add(E agent) |
This method should not be called by user
Call add_EONAME() method of class containing embedded object
with name EONAME or agent.goToPopulation( population ) |
boolean |
_remove(Agent agent) |
This method should not be called by user
Call remove_EONAME() method of class containing embedded
object with name EONAME or agent.goToPopulation( null ) |
boolean |
contains(java.lang.Object agent) |
Returns
true if this agent population contains the
specified element. |
E |
get(int index) |
Returns the agent element at the specified position in this
agent population.
This method is extremely slow when rapidly calling it with random index for large collections |
boolean |
isEmpty() |
Returns
true if this agent population contains no
elements. |
java.util.Iterator<E> |
iterator() |
Returns an iterator over the agent population.
This iterator guarantees the insertion order of elements (i.e. |
int |
size() |
Returns the number of elements in this agent population.
If this collection contains more than Integer.MAX_VALUE
elements, returns Integer.MAX_VALUE . |
java.util.stream.Stream<E> |
stream() |
Returns a sequential Stream with this agent population as its source.
|
java.lang.String |
toString() |
|
Modifier and Type | Method | Description |
---|
average, average, callCreate, callCreate, callSetupParameters, callSetupParameters, count, fillFromTable, fillFromTable, fillFromTable, findAll, findFirst, getEnvironment, getOwner, getPresentationScaleOnOwnerSpace, getValueFromTable, instantiateAgent, isPresentationEnabled, max, max, min, min, min, onChange, random, random, randomExcept, randomExcept, restoreOwner, setEnvironment, sum, sum
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
forEach, spliterator
public AgentLinkedHashSet(Agent owner)
public boolean contains(java.lang.Object agent)
Returns
Operation runs in about constant time
true
if this agent population 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))
.Operation runs in about constant time
- Specified by:
contains
in classAgentList<E extends Agent>
- Parameters:
agent
- element whose presence in this agent population is to be tested- Returns:
true
if this agent population contains the specified element
public boolean isEmpty()
Description copied from class:
AgentList
Returns
true
if this agent population contains no
elements.- Specified by:
isEmpty
in classAgentList<E extends Agent>
- Returns:
true
if this agent population contains no elements
public java.util.Iterator<E> iterator()
Returns an iterator over the agent population.
This iterator guarantees the insertion order of elements (i.e. the order in which agent were added to this replicated agent list).
This iterator guarantees the insertion order of elements (i.e. the order in which agent were added to this replicated agent list).
- Specified by:
iterator
in interfacejava.lang.Iterable<E extends Agent>
- Specified by:
iterator
in classAgentList<E extends Agent>
- Returns:
- an
Iterator
over the elements in this replicated agent
public java.util.stream.Stream<E> stream()
Description copied from class:
AgentList
Returns a sequential Stream with this agent population as its source.
public int size()
Description copied from class:
AgentList
Returns the number of elements in this agent population.
If this collection contains more than
If this collection contains more than
Integer.MAX_VALUE
elements, returns Integer.MAX_VALUE
.- Specified by:
size
in classAgentList<E extends Agent>
- Returns:
- the number of elements in this agent population
public E get(int index)
Returns the agent element at the specified position in this
agent population.
This method is extremely slow when rapidly calling it with random index for large collections
This method is extremely slow when rapidly calling it with random index for large collections
- Specified by:
get
in classAgentList<E extends Agent>
- Parameters:
index
- index of the element to return- Returns:
- the element at the specified position in this list
- Throws:
java.lang.IndexOutOfBoundsException
- if the index is out of range (index < 0 || index >= size()
)
@AnyLogicInternalCodegenAPI public void _add(E agent)
Description copied from class:
AgentList
This method should not be called by user
Call
Call
add_EONAME()
method of class containing embedded object
with name EONAME or agent.goToPopulation( population )
@AnyLogicInternalCodegenAPI public boolean _remove(Agent agent)
Description copied from class:
AgentList
This method should not be called by user
Call
Call
remove_EONAME()
method of class containing embedded
object with name EONAME or agent.goToPopulation( null )
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
How can we improve this article?
-