uk.ac.leeds.ccg.andyt.projects.genesis.core
Class GENESIS_AgentCollection

java.lang.Object
  extended by uk.ac.leeds.ccg.andyt.projects.genesis.core.GENESIS_AgentCollection
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
GENESIS_FemaleCollection, GENESIS_MaleCollection

public abstract class GENESIS_AgentCollection
extends java.lang.Object
implements java.io.Serializable

Each Agent has a reference to at least one AgentCollection. This class contains methods for creating and deleting the file store/cache. Contains methods and collections for managing access to Agents with this store.

See Also:
Serialized Form

Field Summary
protected  java.util.HashMap<java.lang.Long,GENESIS_Agent> _Agent_ID_Agent_HashMap
          keys are long _AgentID, values are Agents.
protected  long _AgentCollection_ID
           
protected  java.io.File _Directory
          The File which is used to swap data.
protected  GENESIS_AgentCollectionManager _GENESIS_AgentCollectionManager
           
 GENESIS_Environment _GENESIS_Environment
           
protected  java.lang.String _Type
          For recording the type (getClass().getName())of Agents _AgentID_Agent_HashMap contains.
 
Constructor Summary
GENESIS_AgentCollection()
           
 
Method Summary
 java.util.HashMap<java.lang.Long,GENESIS_Agent> get_Agent_ID_Agent_HashMap()
           
 java.io.File get_AgentCollectionManager_Directory()
           
 GENESIS_AgentCollectionManager get_AgentCollectionManager()
           
protected  java.io.File get_File()
           
protected  java.lang.String get_Type()
           
 long getAgentCollection_ID()
           
abstract  java.io.File getDirectory()
           
 java.lang.Long getMaxAgentID()
          This would be a lot easier if the data were stored in a TreeMap rather than a HashMap!
 java.lang.Long getMaxAgentID(java.lang.Long minAgentID)
           
 java.lang.Long getMinAgentID()
           
 java.util.HashSet getPossibleAgentIDs_HashSet()
           
protected  void init_AgentID_Agent_HashMap()
           
 boolean isInMemory()
           
 boolean remove(java.lang.Long a_AgentID)
           _Agent_ID_Agent_HashMap.remove(a_AgentID); if (_Agent_ID_Agent_HashMap.isEmpty()){ return true; } else { return false; }
protected  void swapToFileAgent(java.lang.Long a_Agent_ID)
           
protected  void swapToFileAgentExcept(java.lang.Long a_Agent_ID)
           
protected  void swapToFileAgents()
           
protected  void swapToFileAgentsExcept(java.lang.Long a_Agent_ID)
           
protected  void write()
           
abstract  void write(boolean handleOutOfMemoryError)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_GENESIS_Environment

public transient GENESIS_Environment _GENESIS_Environment

_Directory

protected java.io.File _Directory
The File which is used to swap data.


_AgentCollection_ID

protected long _AgentCollection_ID

_GENESIS_AgentCollectionManager

protected transient GENESIS_AgentCollectionManager _GENESIS_AgentCollectionManager

_Type

protected java.lang.String _Type
For recording the type (getClass().getName())of Agents _AgentID_Agent_HashMap contains.


_Agent_ID_Agent_HashMap

protected java.util.HashMap<java.lang.Long,GENESIS_Agent> _Agent_ID_Agent_HashMap
keys are long _AgentID, values are Agents.

Constructor Detail

GENESIS_AgentCollection

public GENESIS_AgentCollection()
Method Detail

get_Agent_ID_Agent_HashMap

public java.util.HashMap<java.lang.Long,GENESIS_Agent> get_Agent_ID_Agent_HashMap()

isInMemory

public boolean isInMemory()

get_AgentCollectionManager_Directory

public java.io.File get_AgentCollectionManager_Directory()

get_AgentCollectionManager

public GENESIS_AgentCollectionManager get_AgentCollectionManager()

get_Type

protected java.lang.String get_Type()

getDirectory

public abstract java.io.File getDirectory()

get_File

protected java.io.File get_File()

init_AgentID_Agent_HashMap

protected void init_AgentID_Agent_HashMap()

remove

public boolean remove(java.lang.Long a_AgentID)
_Agent_ID_Agent_HashMap.remove(a_AgentID); if (_Agent_ID_Agent_HashMap.isEmpty()){ return true; } else { return false; }

Parameters:
a_AgentID -
Returns:
true iff after removing entry _Agent_ID_Agent_HashMap is empty

write

public abstract void write(boolean handleOutOfMemoryError)

write

protected void write()

swapToFileAgents

protected void swapToFileAgents()

swapToFileAgent

protected void swapToFileAgent(java.lang.Long a_Agent_ID)

swapToFileAgentExcept

protected void swapToFileAgentExcept(java.lang.Long a_Agent_ID)

swapToFileAgentsExcept

protected void swapToFileAgentsExcept(java.lang.Long a_Agent_ID)

getAgentCollection_ID

public long getAgentCollection_ID()
Returns:
the _AgentCollection_ID

getMinAgentID

public java.lang.Long getMinAgentID()

getMaxAgentID

public java.lang.Long getMaxAgentID(java.lang.Long minAgentID)
Parameters:
minAgentID -
Returns:
The maximum AgentID this collection will store

getMaxAgentID

public java.lang.Long getMaxAgentID()
This would be a lot easier if the data were stored in a TreeMap rather than a HashMap!

Returns:
The maximum AgentID stored in this collection (which may not be full).

getPossibleAgentIDs_HashSet

public java.util.HashSet getPossibleAgentIDs_HashSet()