rheolef  6.5
msg_right_permutation_apply.h
Go to the documentation of this file.
1 #ifndef _RHEO_MSG_RIGHT_PERMUTATION_APPLY_H
2 #define _RHEO_MSG_RIGHT_PERMUTATION_APPLY_H
3 namespace rheolef {
30 template <
31  class InputIterator,
32  class InputRandomIterator,
33  class OutputIterator,
34  class SetOp>
35 OutputIterator
37  InputIterator perm,
38  InputIterator last_perm,
39  const InputRandomIterator& x,
40  OutputIterator y,
41  SetOp set_op)
42 {
43  for (; perm != last_perm; y++, perm++) {
44  set_op (y, x, *perm);
45  }
46  return y;
47 }
48 @endcode
49 
50 // set(rhs,lhs,i) <==> *rhs = lhs[i] or *rhs = pair(i,rhs[i])
51 
52 // 1) used by csr<Float>:
53 template<class OutputIterator, class InputRandomIterator, class Size>
55  void operator() (OutputIterator rhs, const InputRandomIterator& lhs, Size i) {
56  *rhs = lhs [i];
57  }
58 };
59 template <
60  class InputIterator,
61  class InputRandomIterator,
62  class OutputIterator>
63 inline
64 OutputIterator
66  InputIterator perm,
67  InputIterator last_perm,
68  const InputRandomIterator& x,
69  OutputIterator y)
70 {
71  typedef typename std::iterator_traits<InputIterator>::value_type size_type;
73  return msg_right_permutation_apply (perm, last_perm, x, y, set_op);
74 }
75 #ifdef TO_CLEAN
76 // used by polymorphic_array<geo_element> in geo<Float>:
77 template<class OutputIterator, class InputRandomIterator, class Size>
78 struct msg_right_permutation_set_pair {
79  typedef typename std::iterator_traits<OutputIterator>::value_type T;
80  void operator() (OutputIterator rhs, const InputRandomIterator& lhs, Size i) {
81  *rhs = std::pair<Size,T>(i,lhs [i]);
82  }
83 };
84 #endif // TO_CLEAN
85 
86 
87 } // namespace rheolef
88 #endif // _RHEO_MSG_RIGHT_PERMUTATION_APPLY_H
89