add return of number of alive agents from AgentList

This commit is contained in:
Stephen Birarda 2013-07-02 10:34:57 -07:00
parent ef8c48245e
commit 2a4d9c98ee
2 changed files with 13 additions and 0 deletions

View file

@ -191,6 +191,18 @@ Agent* AgentList::agentWithID(uint16_t agentID) {
return NULL;
}
int AgentList::numAliveAgents() const {
int numAliveAgents = 0;
for (AgentList::iterator agent = begin(); agent != end(); agent++) {
if (agent->isAlive()) {
++numAliveAgents;
}
}
return numAliveAgents;
}
void AgentList::setAgentTypesOfInterest(const char* agentTypesOfInterest, int numAgentTypesOfInterest) {
delete _agentTypesOfInterest;

View file

@ -63,6 +63,7 @@ public:
void(*linkedDataCreateCallback)(Agent *);
int size() { return _numAgents; }
int numAliveAgents() const;
void lock() { pthread_mutex_lock(&mutex); }
void unlock() { pthread_mutex_unlock(&mutex); }