OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
BasicPairBuilder.h
Go to the documentation of this file.
1 #ifndef BASIC_PAIR_BUILDER_H
2 #define BASIC_PAIR_BUILDER_H
3 
4 #include <algorithm>
5 
6 template<class PBase>
8 {
9 public:
10  enum { Dim = PBase::Dim };
11  typedef typename PBase::Position_t Position_t;
12 
13  BasicPairBuilder(PBase &p) : particles(p) { }
14 
15  template<class Pred, class OP>
16  void for_each(const Pred& pred, const OP &op)
17  {
18  std::size_t size = particles.getLocalNum()+particles.getGhostNum();
19  for(std::size_t i = 0;i<size;++i)
20  for(std::size_t j = i+1;j<size;++j)
21  if(pred(particles.R[i], particles.R[j]))
22  op(i, j, particles);
23  }
24 private:
25  PBase &particles;
26 };
27 
28 #endif
PBase::Position_t Position_t
Position_t
Definition: Types.h:28
void for_each(const Pred &pred, const OP &op)
BasicPairBuilder(PBase &p)
const unsigned Dim