CMS 3D CMS Logo

isMonotonous.h
Go to the documentation of this file.
1 #ifndef NPSTAT_ISMONOTONOUS_HH_
2 #define NPSTAT_ISMONOTONOUS_HH_
3 
15 namespace npstat {
17  template <class Iter>
18  inline bool isStrictlyIncreasing(Iter begin, Iter const end) {
19  if (begin == end)
20  return false;
21  Iter first(begin);
22  bool status = ++begin != end;
23  for (; begin != end && status; ++begin, ++first)
24  if (!(*first < *begin))
25  status = false;
26  return status;
27  }
28 
30  template <class Iter>
31  inline bool isStrictlyDecreasing(Iter begin, Iter const end) {
32  if (begin == end)
33  return false;
34  Iter first(begin);
35  bool status = ++begin != end;
36  for (; begin != end && status; ++begin, ++first)
37  if (!(*begin < *first))
38  status = false;
39  return status;
40  }
41 
43  template <class Iter>
44  inline bool isStrictlyMonotonous(Iter const begin, Iter const end) {
45  return isStrictlyIncreasing(begin, end) || isStrictlyDecreasing(begin, end);
46  }
47 
49  template <class Iter>
50  inline bool isNonDecreasing(Iter begin, Iter const end) {
51  if (begin == end)
52  return false;
53  Iter first(begin);
54  bool status = ++begin != end;
55  for (; begin != end && status; ++begin, ++first)
56  if (*begin < *first)
57  status = false;
58  return status;
59  }
60 
62  template <class Iter>
63  inline bool isNonIncreasing(Iter begin, Iter const end) {
64  if (begin == end)
65  return false;
66  Iter first(begin);
67  bool status = ++begin != end;
68  for (; begin != end && status; ++begin, ++first)
69  if (*begin > *first)
70  status = false;
71  return status;
72  }
73 
78  template <class Iter>
79  inline bool isMonotonous(Iter const begin, Iter const end) {
80  return isNonDecreasing(begin, end) || isNonIncreasing(begin, end);
81  }
82 } // namespace npstat
83 
84 #endif // NPSTAT_ISMONOTONOUS_HH_
mps_update.status
status
Definition: mps_update.py:68
npstat::isNonIncreasing
bool isNonIncreasing(Iter begin, Iter const end)
Definition: isMonotonous.h:63
npstat::isStrictlyMonotonous
bool isStrictlyMonotonous(Iter const begin, Iter const end)
Definition: isMonotonous.h:44
npstat
Definition: AbsArrayProjector.h:14
mps_fire.end
end
Definition: mps_fire.py:242
npstat::isStrictlyIncreasing
bool isStrictlyIncreasing(Iter begin, Iter const end)
Definition: isMonotonous.h:18
first
auto first
Definition: CAHitNtupletGeneratorKernelsImpl.h:125
npstat::isStrictlyDecreasing
bool isStrictlyDecreasing(Iter begin, Iter const end)
Definition: isMonotonous.h:31
npstat::isMonotonous
bool isMonotonous(Iter const begin, Iter const end)
Definition: isMonotonous.h:79
npstat::isNonDecreasing
bool isNonDecreasing(Iter begin, Iter const end)
Definition: isMonotonous.h:50