CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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  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_
bool isStrictlyIncreasing(Iter begin, Iter const end)
Definition: isMonotonous.h:18
list status
Definition: mps_update.py:107
bool isStrictlyDecreasing(Iter begin, Iter const end)
Definition: isMonotonous.h:31
bool isStrictlyMonotonous(Iter const begin, Iter const end)
Definition: isMonotonous.h:44
bool isNonDecreasing(Iter begin, Iter const end)
Definition: isMonotonous.h:50
string end
Definition: dataset.py:937
bool isNonIncreasing(Iter begin, Iter const end)
Definition: isMonotonous.h:63
bool isMonotonous(Iter const begin, Iter const end)
Definition: isMonotonous.h:79