Package HAL.GridsAndAgents
Class AgentList<T>
- java.lang.Object
-
- HAL.GridsAndAgents.AgentList<T>
-
- Type Parameters:
T
- the type of agent that the AgentList will hold
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Iterable<T>
public class AgentList<T> extends java.lang.Object implements java.lang.Iterable<T>, java.io.Serializable
AgentLists can hold any type of agent- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description AgentList()
creates an empty AgentList
-
Method Summary
Modifier and Type Method Description void
AddAgent(T agent)
adds an agent to the AgentList, agents can be added multiple times.void
CleanAgents()
may speed up AgentList iteration if many agents from the AgentList have died recentlyvoid
CleanShuffle(Rand rn)
int
GetPop()
returns the size of the AgentList, duplicate agents will be counted multiple timesboolean
InList(T agent)
returns whether a given agent is already in the AgentListjava.util.Iterator<T>
iterator()
T
RandomAgent(Rand rn)
returns a random agent from the AgentListint
RemoveAgent(T agent)
removes all instances of the agent from the AgentList, returns the number of instances removedvoid
ShuffleAgents(Rand rn)
Shuffles the agentlist order (Don't run during agent iteration)
-
-
-
Method Detail
-
InList
public boolean InList(T agent)
returns whether a given agent is already in the AgentList
-
GetPop
public int GetPop()
returns the size of the AgentList, duplicate agents will be counted multiple times
-
AddAgent
public void AddAgent(T agent)
adds an agent to the AgentList, agents can be added multiple times.
-
RemoveAgent
public int RemoveAgent(T agent)
removes all instances of the agent from the AgentList, returns the number of instances removed
-
CleanShuffle
public void CleanShuffle(Rand rn)
-
ShuffleAgents
public void ShuffleAgents(Rand rn)
Shuffles the agentlist order (Don't run during agent iteration)
-
CleanAgents
public void CleanAgents()
may speed up AgentList iteration if many agents from the AgentList have died recently
-
-