66 std::map<int, Type>&
data()
73 typename std::map<int, Type>::iterator it;
75 for(it =
data_.begin(); it !=
data_.end(); it++) {
76 std::cout<<
"---"<<it->first<<
","<<it->second<<
"---"<<std::endl;
80 void foreach(
void(*f)(Type))
82 typename std::map<int, Type>::iterator n_it;
84 for(n_it =
data_.begin(); n_it !=
data_.end(); n_it++) {
89 void foreach(
const boost::function<
void(Type)>&
f)
91 typename std::map<int, Type>::iterator n_it;
93 for(n_it =
data_.begin(); n_it !=
data_.end(); n_it++) {
102 typename std::map<int, Type>::iterator n_it1;
104 for(n_it1 =
data_.begin(); n_it1 !=
data_.end(); n_it1++) {
105 T2 temp = (*f)(n_it1->second);
106 n2.
data_.insert(std::pair<int, T2>(n_it1->first,temp));
115 typename std::map<int, Type>::iterator n_it1;
117 for(n_it1 =
data_.begin(); n_it1 !=
data_.end(); n_it1++) {
118 T2 temp =
f(n_it1->second);
119 n2.
data_.insert(std::pair<int, T2>(n_it1->first,temp));
127 typename std::map<int, Type>::iterator n_it1;
129 for(n_it1 =
data_.begin(); n_it1 !=
data_.end(); n_it1++) {
130 t2 = (*f)(n_it1->second, t2);
137 T2
reduce(
const boost::function<T2(Type, T2&)>& f, T2& t2)
139 typename std::map<int, Type>::iterator n_it1;
141 for(n_it1 =
data_.begin(); n_it1 !=
data_.end(); n_it1++) {
142 t2 =
f(n_it1->second, t2);
152 typename std::map<int, Type>::iterator n_it;
154 for(n_it =
data_.begin(); n_it !=
data_.end(); n_it++) {
155 if((*
f)(n_it->first, n_it->second)) {
156 result.
data_.insert(std::pair<int, Type>(n_it->first,n_it->second));
166 typename std::map<int, Type>::iterator n_it;
168 for(n_it =
data_.begin(); n_it !=
data_.end(); n_it++) {
169 if(
f(n_it->first, n_it->second)) {
170 result.
data_.insert(std::pair<int, Type>(n_it->first,n_it->second));
180 typename std::map<int, Type>::iterator n_it;
182 for(n_it =
data_.begin(); n_it !=
data_.end(); n_it++) {
183 if(
rth_->inNeighborSwarm(n_it->first, swarm_id)) {
184 result.
data_.insert(std::pair<int, Type>(n_it->first,n_it->second));
195 typename std::map<int, Type>::iterator n_it;
197 for(n_it =
data_.begin(); n_it !=
data_.end(); n_it++) {
198 if(!
rth_->inNeighborSwarm(n_it->first, swarm_id)) {
199 result.
data_.insert(std::pair<int, Type>(n_it->first,n_it->second));
256 std::map<int, NeighborBase>&
data()
263 typename std::map<int, NeighborBase>::iterator it;
265 for(it =
data_.begin(); it !=
data_.end(); it++) {
266 std::cout<<
"---"<<it->first<<
": "<<it->second.distance<<
","<< \
267 it->second.azimuth<<
","<<it->second.elevation<<
","<< \
268 it->second.x<<
","<<it->second.y<<
","<<it->second.z<< \
269 it->second.vx<<
","<<it->second.vy<<
","<<it->second.vz<< \
276 typename std::map<int, NeighborBase>::iterator n_it;
278 for(n_it =
data_.begin(); n_it !=
data_.end(); n_it++) {
285 typename std::map<int, NeighborBase>::iterator n_it;
287 for(n_it =
data_.begin(); n_it !=
data_.end(); n_it++) {
296 typename std::map<int, NeighborBase>::iterator n_it;
298 for(n_it =
data_.begin(); n_it !=
data_.end(); n_it++) {
299 T temp = (*f)(n_it->second);
300 n.
data_.insert(std::pair<int, T>(n_it->first,temp));
310 typename std::map<int, NeighborBase>::iterator n_it;
312 for(n_it =
data_.begin(); n_it !=
data_.end(); n_it++) {
313 T temp =
f(n_it->second);
314 n.
data_.insert(std::pair<int, T>(n_it->first,temp));
323 typename std::map<int, NeighborBase>::iterator n_it;
325 for(n_it =
data_.begin(); n_it !=
data_.end(); n_it++) {
326 t = (*f)(n_it->second, t);
335 typename std::map<int, NeighborBase>::iterator n_it;
337 for(n_it =
data_.begin(); n_it !=
data_.end(); n_it++) {
338 t =
f(n_it->second, t);
348 typename std::map<int, NeighborBase>::iterator n_it;
350 for(n_it =
data_.begin(); n_it !=
data_.end(); n_it++) {
351 if((*
f)(n_it->first, n_it->second)) {
352 result.
data_.insert(std::pair<int, NeighborBase>(n_it->first,n_it->second));
363 typename std::map<int, NeighborBase>::iterator n_it;
365 for(n_it =
data_.begin(); n_it !=
data_.end(); n_it++) {
366 if(
f(n_it->first, n_it->second)) {
367 result.
data_.insert(std::pair<int, NeighborBase>(n_it->first,n_it->second));
378 typename std::map<int, NeighborBase>::iterator n_it;
380 for(n_it =
data_.begin(); n_it !=
data_.end(); n_it++) {
381 if(
rth_->inNeighborSwarm(n_it->first, swarm_id)) {
382 result.
data_.insert(std::pair<int, NeighborBase>(n_it->first,n_it->second));
393 typename std::map<int, NeighborBase>::iterator n_it;
395 for(n_it =
data_.begin(); n_it !=
data_.end(); n_it++) {
396 if(!
rth_->inNeighborSwarm(n_it->first, swarm_id)) {
397 result.
data_.insert(std::pair<int, NeighborBase>(n_it->first,n_it->second));
Neighbors< NeighborBase > filter(bool(*f)(int, NeighborBase))
Neighbors(const Neighbors< NeighborBase > &n)
Neighbors< T > map(T(*f)(NeighborBase))
boost::shared_ptr< RuntimeHandle > rth_
Neighbors< Type > nonkin(int swarm_id)
std::map< int, NeighborBase > & data()
Neighbors< Type > filter(const boost::function< bool(int, Type)> &f)
std::map< int, Type > data_
Neighbors< NeighborBase > nonkin(int swarm_id)
Neighbors(bool get_data_now)
Neighbors & operator=(const Neighbors< Type > &n)
Neighbors< T > map(const boost::function< T(NeighborBase)> &f)
T reduce(T(*f)(NeighborBase, T &), T &t)
Neighbors< NeighborBase > filter(const boost::function< bool(int, NeighborBase)> &f)
std::map< int, Type > & data()
boost::shared_ptr< RuntimeHandle > rth_
T2 reduce(const boost::function< T2(Type, T2 &)> &f, T2 &t2)
static boost::shared_ptr< T > getSingleton()
Neighbors(const Neighbors< Type > &n)
Neighbors< Type > filter(bool(*f)(int, Type))
Neighbors & operator=(const Neighbors< NeighborBase > &n)
Neighbors< Type > kin(int swarm_id)
Neighbors< T2 > map(const boost::function< T2(Type)> &f)
std::map< int, NeighborBase > data_
T reduce(const boost::function< T(NeighborBase, T &)> &f, T &t)
Neighbors< NeighborBase > kin(int swarm_id)
T2 reduce(T2(*f)(Type, T2 &), T2 &t2)
Neighbors< T2 > map(T2(*f)(Type))