Class 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 recently
      void CleanShuffle​(Rand rn)  
      int GetPop()
      returns the size of the AgentList, duplicate agents will be counted multiple times
      boolean InList​(T agent)
      returns whether a given agent is already in the AgentList
      java.util.Iterator<T> iterator()  
      T RandomAgent​(Rand rn)
      returns a random agent from the AgentList
      int RemoveAgent​(T agent)
      removes all instances of the agent from the AgentList, returns the number of instances removed
      void ShuffleAgents​(Rand rn)
      Shuffles the agentlist order (Don't run during agent iteration)
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.lang.Iterable

        forEach, spliterator
    • Constructor Detail

      • AgentList

        public AgentList()
        creates an empty AgentList
    • 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
      • RandomAgent

        public T RandomAgent​(Rand rn)
        returns a random agent from the AgentList
      • iterator

        public java.util.Iterator<T> iterator()
        Specified by:
        iterator in interface java.lang.Iterable<T>