C++ main module for emicrom Package  1.0
OMP_ArrayElement.h
Go to the documentation of this file.
1 #ifndef OMP_ArrayElement_H
2 #define OMP_ArrayElement_H
3 
4 #include "CORE_Object.h"
5 
6 template<class T>
8 private:
9  T mValue;
10  size_t mIndex;
11 public:
16  mValue=S.value();
17  mIndex=S.index();
18  }
23  OMP_ArrayElement(const T& v,const size_t& i) {
24  mValue=v;
25  mIndex=i;
26  }
30  mValue=0;
31  mIndex=0;
32  }
36  }
37 
38  //operator
39 
44  inline tBoolean operator<(const OMP_ArrayElement<T>& elt) const {
45  return (mValue<elt.value());
46  }
51  inline tBoolean operator<=(const OMP_ArrayElement<T>& elt) const {
52  return (mValue<=elt.value());
53  }
58  inline tBoolean operator>(const OMP_ArrayElement<T>& elt) const {
59  return (mValue>elt.value());
60  }
65  inline tBoolean operator>=(const OMP_ArrayElement<T>& elt) const {
66  return (mValue>=elt.value());
67  }
72  inline tBoolean operator==(const OMP_ArrayElement<T>& elt) const {
73  return (fabs(mValue-elt.value())<CORE_Object::getEpsilon<T>());
74  }
79  inline tBoolean operator!=(const OMP_ArrayElement<T>& elt) const {
80  return (fabs(mValue-elt.value())>CORE_Object::getEpsilon<T>());
81  }
82 
83 
87  inline const T& value() const {
88  return mValue;
89  }
90 
94  inline T& value() {
95  return mValue;
96  }
97 
101  inline const size_t& index() const {
102  return mIndex;
103  }
107  inline size_t& index() {
108  return mIndex;
109  }
115  inline void setElement(const T& v,const size_t& i) {
116  mValue=v;
117  mIndex=i;
118  }
119 
125  static inline const OMP_ArrayElement<T>& min(const OMP_ArrayElement<T>& a,
126  const OMP_ArrayElement<T>& b) {
127  return (a.value()<b.value()) ? a : b;
128  }
134  static inline const OMP_ArrayElement<T>& max(const OMP_ArrayElement<T>& a,
135  const OMP_ArrayElement<T>& b) {
136  return (a.value()>b.value()) ? a : b;
137  }
143  static inline const std::pair<T,tUIndex>& pmin(const std::pair<T,tUIndex>& a,
144  const std::pair<T,tUIndex>& b) {
145  return (a.first<b.first) ? a : b;
146  }
147 
153  static inline const std::pair<T,tUIndex>& pmax(const std::pair<T,tUIndex>& a,
154  const std::pair<T,tUIndex>& b) {
155  return (a.first>b.first) ? a : b;
156  }
157 
158 
159 };
160 
161 
162 #endif
void setElement(const T &v, const size_t &i)
set the value and index of the element
Definition: OMP_ArrayElement.h:115
OMP_ArrayElement(const OMP_ArrayElement &S)
create a new copy instance of the array element S
Definition: OMP_ArrayElement.h:15
tBoolean operator!=(const OMP_ArrayElement< T > &elt) const
compare 2 elements
Definition: OMP_ArrayElement.h:79
size_t & index()
return the index of the element
Definition: OMP_ArrayElement.h:107
T mValue
Definition: OMP_ArrayElement.h:9
static const std::pair< T, tUIndex > & pmin(const std::pair< T, tUIndex > &a, const std::pair< T, tUIndex > &b)
return the min element of a & b
Definition: OMP_ArrayElement.h:143
#define tBoolean
Definition: types.h:139
size_t mIndex
Definition: OMP_ArrayElement.h:10
tBoolean operator==(const OMP_ArrayElement< T > &elt) const
compare 2 elements
Definition: OMP_ArrayElement.h:72
static const OMP_ArrayElement< T > & max(const OMP_ArrayElement< T > &a, const OMP_ArrayElement< T > &b)
return the max element of a & b
Definition: OMP_ArrayElement.h:134
static const OMP_ArrayElement< T > & min(const OMP_ArrayElement< T > &a, const OMP_ArrayElement< T > &b)
return the min element of a & b
Definition: OMP_ArrayElement.h:125
tBoolean operator>(const OMP_ArrayElement< T > &elt) const
compare 2 elements
Definition: OMP_ArrayElement.h:58
OMP_ArrayElement()
create a default array element
Definition: OMP_ArrayElement.h:29
tBoolean operator>=(const OMP_ArrayElement< T > &elt) const
compare 2 elements
Definition: OMP_ArrayElement.h:65
Definition: OMP_ArrayElement.h:7
const size_t & index() const
return the index of the element
Definition: OMP_ArrayElement.h:101
const T & value() const
return the value of the element
Definition: OMP_ArrayElement.h:87
T & value()
return the value of the element
Definition: OMP_ArrayElement.h:94
OMP_ArrayElement(const T &v, const size_t &i)
create an instance of Array Element with initial value
Definition: OMP_ArrayElement.h:23
~OMP_ArrayElement()
destroy the array element
Definition: OMP_ArrayElement.h:35
static const std::pair< T, tUIndex > & pmax(const std::pair< T, tUIndex > &a, const std::pair< T, tUIndex > &b)
return the max element of a & b
Definition: OMP_ArrayElement.h:153