CMS 3D CMS Logo

Algorithms.h
Go to the documentation of this file.
1 #ifndef FWCore_Utilities_Algorithms_h
2 #define FWCore_Utilities_Algorithms_h
3 
4 #include <algorithm>
5 
6 namespace edm {
7 
11 
13  template <typename ForwardSequence, typename Func>
14  inline
15  Func
16  for_all(ForwardSequence& s, Func f) {
17  return std::for_each(s.begin(), s.end(), f);
18  }
19 
21  template <typename ForwardSequence, typename Func>
22  inline
23  Func
24  copy_all(ForwardSequence& s, Func f) {
25  return std::copy(s.begin(), s.end(), f);
26  }
27 
29  template <typename ForwardSequence, typename Datum>
30  inline
31  typename ForwardSequence::const_iterator
32  find_in_all(ForwardSequence const& s, Datum const& d) {
33  return std::find(s.begin(), s.end(), d);
34  }
35 
36  template <typename ForwardSequence, typename Datum>
37  inline
38  typename ForwardSequence::iterator
39  find_in_all(ForwardSequence& s, Datum const& d) {
40  return std::find(s.begin(), s.end(), d);
41  }
42 
43  template <typename ForwardSequence, typename Datum>
44  inline
45  bool
46  search_all(ForwardSequence const& s, Datum const& d) {
47  return std::find(s.begin(), s.end(), d) != s.end();
48  }
49 
51  template <typename ForwardSequence, typename Predicate>
52  inline
53  typename ForwardSequence::const_iterator
54  find_if_in_all(ForwardSequence const& s, Predicate const& p) {
55  return std::find_if(s.begin(), s.end(), p);
56  }
57 
58  template <typename ForwardSequence, typename Predicate>
59  inline
60  typename ForwardSequence::iterator
61  find_if_in_all(ForwardSequence& s, Predicate const& p) {
62  return std::find_if(s.begin(), s.end(), p);
63  }
64 
65  template <typename ForwardSequence, typename Predicate>
66  inline
67  bool
68  search_if_in_all(ForwardSequence const& s, Predicate const& p) {
69  return std::find_if(s.begin(), s.end(), p) != s.end();
70  }
71 
73  template <typename ForwardSequence, typename Datum>
74  inline
75  bool
76  binary_search_all(ForwardSequence const& s, Datum const& d) {
77  return std::binary_search(s.begin(), s.end(), d);
78  }
79 
80  template <typename ForwardSequence, typename Datum, typename Predicate>
81  inline
82  bool
83  binary_search_all(ForwardSequence const& s, Datum const& d, Predicate p) {
84  return std::binary_search(s.begin(), s.end(), d, p);
85  }
86 
88  template <typename ForwardSequence, typename Datum>
89  inline
90  typename ForwardSequence::const_iterator
91  lower_bound_all(ForwardSequence const& s, Datum const& d) {
92  return std::lower_bound(s.begin(), s.end(), d);
93  }
94 
95  template <typename ForwardSequence, typename Datum>
96  inline
97  typename ForwardSequence::iterator
98  lower_bound_all(ForwardSequence& s, Datum const& d) {
99  return std::lower_bound(s.begin(), s.end(), d);
100  }
101 
102  template <typename ForwardSequence, typename Datum, typename Predicate>
103  inline
104  typename ForwardSequence::const_iterator
105  lower_bound_all(ForwardSequence const& s, Datum const& d, Predicate p) {
106  return std::lower_bound(s.begin(), s.end(), d, p);
107  }
108 
109  template <typename ForwardSequence, typename Datum, typename Predicate>
110  inline
111  typename ForwardSequence::iterator
112  lower_bound_all(ForwardSequence& s, Datum const& d, Predicate p) {
113  return std::lower_bound(s.begin(), s.end(), d, p);
114  }
115 
117  template <typename RandomAccessSequence>
118  inline
119  void
120  sort_all(RandomAccessSequence & s) {
121  std::sort(s.begin(), s.end());
122  }
123 
124  template <typename RandomAccessSequence, typename Predicate>
125  inline
126  void
127  sort_all(RandomAccessSequence & s, Predicate p) {
128  std::sort(s.begin(), s.end(), p);
129  }
130 
132  template <typename RandomAccessSequence>
133  inline
134  void
135  stable_sort_all(RandomAccessSequence & s) {
136  std::stable_sort(s.begin(), s.end());
137  }
138 
139  template <typename RandomAccessSequence, typename Predicate>
140  inline
141  void
142  stable_sort_all(RandomAccessSequence & s, Predicate p) {
143  std::stable_sort(s.begin(), s.end(), p);
144  }
145 }
146 #endif
ForwardSequence::const_iterator lower_bound_all(ForwardSequence const &s, Datum const &d)
wrappers for std::lower_bound
Definition: Algorithms.h:91
bool search_if_in_all(ForwardSequence const &s, Predicate const &p)
Definition: Algorithms.h:68
void stable_sort_all(RandomAccessSequence &s)
wrappers for std::stable_sort
Definition: Algorithms.h:135
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
Func for_all(ForwardSequence &s, Func f)
wrapper for std::for_each
Definition: Algorithms.h:16
double f[11][100]
void sort_all(RandomAccessSequence &s)
wrappers for std::sort
Definition: Algorithms.h:120
ForwardSequence::const_iterator find_in_all(ForwardSequence const &s, Datum const &d)
wrappers for std::find
Definition: Algorithms.h:32
bool search_all(ForwardSequence const &s, Datum const &d)
Definition: Algorithms.h:46
HLT enums.
Func copy_all(ForwardSequence &s, Func f)
wrappers for copy
Definition: Algorithms.h:24
bool binary_search_all(ForwardSequence const &s, Datum const &d)
wrappers for std::binary_search
Definition: Algorithms.h:76
ForwardSequence::const_iterator find_if_in_all(ForwardSequence const &s, Predicate const &p)
wrappers for std::find
Definition: Algorithms.h:54