RepastHPC
2.3.1
|
Specialized indexable collection class for agents. More...
#include <AgentSet.h>
Public Types | |
typedef std::vector< T * >::iterator | as_iterator |
typedef std::vector< T * >::const_iterator | const_as_iterator |
Public Member Functions | |
AgentSet () | |
Creates an empty agent set. | |
template<typename input_iterator > | |
AgentSet (input_iterator start, input_iterator end) | |
Creates an agent set and fills with elements from start through end. | |
AgentSet (const AgentSet &set) | |
Copy constructor. | |
template<typename input_iterator > | |
void | addAll (input_iterator begin, input_iterator end) |
Adds all the agents from the start iterator through the end to this AgentSet. | |
void | add (T *agent) |
Adds an agent to this AgentSet. | |
template<typename Functor > | |
void | ask (Functor func) |
Calls the Functor on each agent in this AgentSet. More... | |
template<typename Functor , typename P1 > | |
void | ask (Functor func, const P1 &p1) |
Calls the Functor on each agent in this AgentSet, passing the specified argument. More... | |
template<typename Functor , typename P1 > | |
void | ask (Functor func, P1 &p1) |
Calls the Functor on each agent in this AgentSet, passing the specified argument. More... | |
template<typename Functor > | |
void | apply (Functor &func) |
Applies the functor to each each agent in the agent set. More... | |
template<typename Functor > | |
void | apply (const Functor &func) |
Applies the functor to each each agent in the agent set. More... | |
T * | at (int index) |
Gets the item at the specified index. More... | |
size_t | count () const |
Gets the size of this AgentSet. More... | |
size_t | size () const |
Gets the size of this AgentSet. More... | |
T * | operator[] (size_t index) |
Gets the item at the specified index without doing any range checking. More... | |
as_iterator | begin () |
Gets an iterator to the begining of this AgentSet. More... | |
const_as_iterator | begin () const |
Gets a const iterator to the begining of this AgentSet. More... | |
as_iterator | end () |
Gets an iterator to the end of this AgentSet. More... | |
const_as_iterator | end () const |
Gets a const iterator to the end of this AgentSet. More... | |
void | clear () |
Clears this AgentSet of any agents that it contains. | |
template<typename ValueGetter > | |
T * | minOneOf (const ValueGetter &getter) |
Gets the set member that has the minimum value of the number returned by ValueGetter. More... | |
template<typename ValueGetter > | |
T * | maxOneOf (const ValueGetter &getter) |
Gets the set member that has the maximum value of the number returned by ValueGetter. More... | |
template<typename ValueGetter > | |
void | withMin (const ValueGetter &getter, AgentSet< T > &set) |
Gets the set members that have the minimum value of the number returned by ValueGetter, and puts them in the specified set. More... | |
template<typename ValueGetter > | |
void | withMax (const ValueGetter &getter, AgentSet< T > &set) |
Gets the set members that have the maximum value of the number returned by ValueGetter and puts them in the specified set. More... | |
template<typename ValueGetter > | |
void | minNOf (size_t count, const ValueGetter &getter, AgentSet< T > &set, bool initialSetIsSorted=false) |
Gets count number of set members that have the minimum value of the number returned by ValueGetter. More... | |
template<typename ValueGetter > | |
void | maxNOf (size_t count, const ValueGetter &getter, AgentSet< T > &set, bool initialSetIsSorted=false) |
T * | oneOf () |
Gets one of the members of this AgentSet at random. More... | |
void | remove (T *agent) |
Removes all instances of the specified agent from this AgentSet. | |
void | shuffle () |
Randomly shuffles the elements of this AgentSet. | |
Public Attributes | |
std::vector< T * > | agents |
Specialized indexable collection class for agents.
This includes methods designed to call arbitrary code on the agents it contains.
T | the type of agent the AgentSet contains |
void repast::relogo::AgentSet< T >::apply | ( | const Functor & | func | ) |
Applies the functor to each each agent in the agent set.
Functor | an object that implements operator()(T* agent); |
void repast::relogo::AgentSet< T >::apply | ( | Functor & | func | ) |
Applies the functor to each each agent in the agent set.
Functor | an object that implements operator()(T* agent); |
void repast::relogo::AgentSet< T >::ask | ( | Functor | func | ) |
void repast::relogo::AgentSet< T >::ask | ( | Functor | func, |
const P1 & | p1 | ||
) |
void repast::relogo::AgentSet< T >::ask | ( | Functor | func, |
P1 & | p1 | ||
) |
T * repast::relogo::AgentSet< T >::at | ( | int | index | ) |
Gets the item at the specified index.
index | the index of the agent to get |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
void repast::relogo::AgentSet< T >::maxNOf | ( | size_t | count, |
const ValueGetter & | getter, | ||
AgentSet< T > & | set, | ||
bool | initialSetIsSorted = false |
||
) |
Gets count number of set members that have the maximum value of the number returned by ValueGetter. If there are not enough to satisfy the count then members with the second lowest value are returned and so on. @param getter the ValueGetter to use in retreiving the value used in the max comparison @tparam ValueGetter a function or functor that takes a member of this agentset and returns a double value. This double value is used in the max comparison.
initialSetIsSorted | Optional performance parameter; if false (the default), a call to this function must sort an entire copy of the original set; if true, the function assumes the original set is already sorted. Useful if the same set is to be used repeatedly. |
T * repast::relogo::AgentSet< T >::maxOneOf | ( | const ValueGetter & | getter | ) |
Gets the set member that has the maximum value of the number returned by ValueGetter.
If more than one agent has the minimum value, then return one of those at random.
getter | the ValueGetter to use in retreiving the value used in the max comparison |
ValueGetter | a function or functor that takes a member of this agentset and returns a double value. This double value is used in the max comparison. |
void repast::relogo::AgentSet< T >::minNOf | ( | size_t | count, |
const ValueGetter & | getter, | ||
AgentSet< T > & | set, | ||
bool | initialSetIsSorted = false |
||
) |
Gets count number of set members that have the minimum value of the number returned by ValueGetter.
If there are not enough to satisfy the count then members with the second lowest value are returned and so on.
getter | the ValueGetter to use in retreiving the value used in the min comparison |
ValueGetter | a function or functor that takes a member of this agentset and returns a double value. This double value is used in the min comparison. |
initialSetIsSorted | Optional performance parameter; if false (the default), a call to this function must sort an entire copy of the original set; if true, the function assumes the original set is already sorted. Useful if the same set is to be used repeatedly. |
T * repast::relogo::AgentSet< T >::minOneOf | ( | const ValueGetter & | getter | ) |
Gets the set member that has the minimum value of the number returned by ValueGetter.
If more than one agent has the minimum value, then return one of those at random.
getter | the ValueGetter to use in retreiving the value used in the min comparison |
ValueGetter | a function or functor that takes a member of this agentset and returns a double value. This double value is used in the min comparison. |
T * repast::relogo::AgentSet< T >::oneOf |
Gets one of the members of this AgentSet at random.
If the set is empty, this returns 0.
T * repast::relogo::AgentSet< T >::operator[] | ( | size_t | index | ) |
Gets the item at the specified index without doing any range checking.
index | the index of the agent to get |
|
inline |
void repast::relogo::AgentSet< T >::withMax | ( | const ValueGetter & | getter, |
AgentSet< T > & | set | ||
) |
Gets the set members that have the maximum value of the number returned by ValueGetter and puts them in the specified set.
getter | the ValueGetter to use in retreiving the value used in the max comparison |
ValueGetter | a function or functor that takes a member of this agentset and returns a double value. This double value is used in the max comparison. |
void repast::relogo::AgentSet< T >::withMin | ( | const ValueGetter & | getter, |
AgentSet< T > & | set | ||
) |
Gets the set members that have the minimum value of the number returned by ValueGetter, and puts them in the specified set.
getter | the ValueGetter to use in retreiving the value used in the min comparison |
ValueGetter | a function or functor that takes a member of this agentset and returns a double value. This double value is used in the min comparison. |