CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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  {
20  if (begin == end)
21  return false;
22  Iter first(begin);
23  bool status = ++begin != end;
24  for (; begin != end && status; ++begin, ++first)
25  if (!(*first < *begin))
26  status = false;
27  return status;
28  }
29 
31  template<class Iter>
32  inline bool isStrictlyDecreasing(Iter begin, Iter const end)
33  {
34  if (begin == end)
35  return false;
36  Iter first(begin);
37  bool status = ++begin != end;
38  for (; begin != end && status; ++begin, ++first)
39  if (!(*begin < *first))
40  status = false;
41  return status;
42  }
43 
45  template<class Iter>
46  inline bool isStrictlyMonotonous(Iter const begin, Iter const end)
47  {
48  return isStrictlyIncreasing(begin, end) ||
49  isStrictlyDecreasing(begin, end);
50  }
51 
53  template<class Iter>
54  inline bool isNonDecreasing(Iter begin, Iter const end)
55  {
56  if (begin == end)
57  return false;
58  Iter first(begin);
59  bool status = ++begin != end;
60  for (; begin != end && status; ++begin, ++first)
61  if (*begin < *first)
62  status = false;
63  return status;
64  }
65 
67  template<class Iter>
68  inline bool isNonIncreasing(Iter begin, Iter const end)
69  {
70  if (begin == end)
71  return false;
72  Iter first(begin);
73  bool status = ++begin != end;
74  for (; begin != end && status; ++begin, ++first)
75  if (*begin > *first)
76  status = false;
77  return status;
78  }
79 
84  template<class Iter>
85  inline bool isMonotonous(Iter const begin, Iter const end)
86  {
87  return isNonDecreasing(begin, end) || isNonIncreasing(begin, end);
88  }
89 }
90 
91 #endif // NPSTAT_ISMONOTONOUS_HH_
92 
bool isStrictlyIncreasing(Iter begin, Iter const end)
Definition: isMonotonous.h:18
bool isStrictlyDecreasing(Iter begin, Iter const end)
Definition: isMonotonous.h:32
#define end
Definition: vmac.h:37
bool first
Definition: L1TdeRCT.cc:75
bool isStrictlyMonotonous(Iter const begin, Iter const end)
Definition: isMonotonous.h:46
bool isNonDecreasing(Iter begin, Iter const end)
Definition: isMonotonous.h:54
#define begin
Definition: vmac.h:30
tuple status
Definition: ntuplemaker.py:245
bool isNonIncreasing(Iter begin, Iter const end)
Definition: isMonotonous.h:68
bool isMonotonous(Iter const begin, Iter const end)
Definition: isMonotonous.h:85