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 Func for_all(ForwardSequence& s, Func f) {
15  return std::for_each(s.begin(), s.end(), f);
16  }
17 
19  template <typename ForwardSequence, typename Func>
20  inline Func copy_all(ForwardSequence& s, Func f) {
21  return std::copy(s.begin(), s.end(), f);
22  }
23 
25  template <typename ForwardSequence, typename Datum>
26  inline typename ForwardSequence::const_iterator find_in_all(ForwardSequence const& s, Datum const& d) {
27  return std::find(s.begin(), s.end(), d);
28  }
29 
30  template <typename ForwardSequence, typename Datum>
31  inline typename ForwardSequence::iterator find_in_all(ForwardSequence& s, Datum const& d) {
32  return std::find(s.begin(), s.end(), d);
33  }
34 
35  template <typename ForwardSequence, typename Datum>
36  inline bool search_all(ForwardSequence const& s, Datum const& d) {
37  return std::find(s.begin(), s.end(), d) != s.end();
38  }
39 
41  template <typename ForwardSequence, typename Predicate>
42  inline typename ForwardSequence::const_iterator find_if_in_all(ForwardSequence const& s, Predicate const& p) {
43  return std::find_if(s.begin(), s.end(), p);
44  }
45 
46  template <typename ForwardSequence, typename Predicate>
47  inline typename ForwardSequence::iterator find_if_in_all(ForwardSequence& s, Predicate const& p) {
48  return std::find_if(s.begin(), s.end(), p);
49  }
50 
51  template <typename ForwardSequence, typename Predicate>
52  inline bool search_if_in_all(ForwardSequence const& s, Predicate const& p) {
53  return std::find_if(s.begin(), s.end(), p) != s.end();
54  }
55 
57  template <typename ForwardSequence, typename Datum>
58  inline bool binary_search_all(ForwardSequence const& s, Datum const& d) {
59  return std::binary_search(s.begin(), s.end(), d);
60  }
61 
62  template <typename ForwardSequence, typename Datum, typename Predicate>
63  inline bool binary_search_all(ForwardSequence const& s, Datum const& d, Predicate p) {
64  return std::binary_search(s.begin(), s.end(), d, p);
65  }
66 
68  template <typename ForwardSequence, typename Datum>
69  inline typename ForwardSequence::const_iterator lower_bound_all(ForwardSequence const& s, Datum const& d) {
70  return std::lower_bound(s.begin(), s.end(), d);
71  }
72 
73  template <typename ForwardSequence, typename Datum>
74  inline typename ForwardSequence::iterator lower_bound_all(ForwardSequence& s, Datum const& d) {
75  return std::lower_bound(s.begin(), s.end(), d);
76  }
77 
78  template <typename ForwardSequence, typename Datum, typename Predicate>
79  inline typename ForwardSequence::const_iterator lower_bound_all(ForwardSequence const& s,
80  Datum const& d,
81  Predicate p) {
82  return std::lower_bound(s.begin(), s.end(), d, p);
83  }
84 
85  template <typename ForwardSequence, typename Datum, typename Predicate>
86  inline typename ForwardSequence::iterator lower_bound_all(ForwardSequence& s, Datum const& d, Predicate p) {
87  return std::lower_bound(s.begin(), s.end(), d, p);
88  }
89 
91  template <typename RandomAccessSequence>
92  inline void sort_all(RandomAccessSequence& s) {
93  std::sort(s.begin(), s.end());
94  }
95 
96  template <typename RandomAccessSequence, typename Predicate>
97  inline void sort_all(RandomAccessSequence& s, Predicate p) {
98  std::sort(s.begin(), s.end(), p);
99  }
100 
102  template <typename RandomAccessSequence>
103  inline void stable_sort_all(RandomAccessSequence& s) {
104  std::stable_sort(s.begin(), s.end());
105  }
106 
107  template <typename RandomAccessSequence, typename Predicate>
108  inline void stable_sort_all(RandomAccessSequence& s, Predicate p) {
109  std::stable_sort(s.begin(), s.end(), p);
110  }
111 } // namespace edm
112 #endif
ForwardSequence::const_iterator lower_bound_all(ForwardSequence const &s, Datum const &d)
wrappers for std::lower_bound
Definition: Algorithms.h:69
bool search_if_in_all(ForwardSequence const &s, Predicate const &p)
Definition: Algorithms.h:52
void stable_sort_all(RandomAccessSequence &s)
wrappers for std::stable_sort
Definition: Algorithms.h:103
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
Func for_all(ForwardSequence &s, Func f)
wrapper for std::for_each
Definition: Algorithms.h:14
double f[11][100]
d
Definition: ztail.py:151
void sort_all(RandomAccessSequence &s)
wrappers for std::sort
Definition: Algorithms.h:92
ForwardSequence::const_iterator find_in_all(ForwardSequence const &s, Datum const &d)
wrappers for std::find
Definition: Algorithms.h:26
bool search_all(ForwardSequence const &s, Datum const &d)
Definition: Algorithms.h:36
HLT enums.
Func copy_all(ForwardSequence &s, Func f)
wrappers for copy
Definition: Algorithms.h:20
bool binary_search_all(ForwardSequence const &s, Datum const &d)
wrappers for std::binary_search
Definition: Algorithms.h:58
ForwardSequence::const_iterator find_if_in_all(ForwardSequence const &s, Predicate const &p)
wrappers for std::find
Definition: Algorithms.h:42