BALL
1.4.1
|
00001 // -*- Mode: C++; tab-width: 2; -*- 00002 // vi: set ts=2: 00003 // 00004 // $Id: triple.h,v 1.9 2003/08/26 08:04:12 oliver Exp $ 00005 // 00006 00007 #ifndef BALL_DATATYPE_TRIPLE_H 00008 #define BALL_DATATYPE_TRIPLE_H 00009 00010 #ifndef BALL_COMMON_H 00011 # include <BALL/common.h> 00012 #endif 00013 00014 namespace BALL 00015 { 00023 template <typename T1, typename T2, typename T3> 00024 class Triple 00025 { 00026 public: 00027 00031 00032 BALL_CREATE(Triple) 00033 00034 00037 Triple(); 00038 00044 Triple(const Triple& triple, bool deep = true); 00045 00053 Triple(const T1& new_first, const T2& new_second, const T3& new_third); 00054 00058 virtual ~Triple(); 00060 00063 virtual void clear(); 00064 00068 00073 const Triple& operator = (const Triple& triple); 00074 00077 void set(const T1& t1, const T2& t2, const T3& t3); 00078 00081 void get(T1& first, T2& second, T3& third) const; 00082 00084 00087 00091 bool operator == (const Triple& triple) const; 00092 00095 bool operator != (const Triple& triple) const; 00096 00102 bool operator < (const Triple& triple) const; 00103 00106 bool operator <= (const Triple& triple) const; 00107 00110 bool operator >= (const Triple& triple) const; 00111 00114 bool operator > (const Triple& triple) const; 00115 00117 00121 00124 T1 first; 00125 00128 T2 second; 00129 00132 T3 third; 00134 }; 00135 00136 template <typename T1, typename T2, typename T3> 00137 Triple<T1, T2, T3>::Triple() 00138 { 00139 } 00140 00141 template <typename T1, typename T2, typename T3> 00142 Triple<T1, T2, T3>::Triple 00143 (const Triple<T1, T2, T3>& triple, bool /* deep */) 00144 : first(triple.first), 00145 second(triple.second), 00146 third(triple.third) { 00147 } 00148 00149 template <typename T1, typename T2, typename T3> 00150 Triple<T1, T2, T3>::Triple 00151 (const T1& new_first, const T2& new_second, const T3& new_third) 00152 : first(new_first), 00153 second(new_second), 00154 third(new_third) 00155 { 00156 } 00157 00158 template <typename T1, typename T2, typename T3> 00159 Triple<T1, T2, T3>::~Triple() 00160 { 00161 } 00162 00163 template <typename T1, typename T2, typename T3> 00164 BALL_INLINE 00165 void Triple<T1, T2, T3>::set(const T1& new_first, const T2& new_second, const T3& new_third) 00166 { 00167 first = new_first; 00168 second = new_second; 00169 third = new_third; 00170 } 00171 00172 template <typename T1, typename T2, typename T3> 00173 BALL_INLINE 00174 const Triple<T1, T2, T3>& Triple<T1, T2, T3>::operator = 00175 (const Triple<T1, T2, T3>& triple) 00176 { 00177 first = triple.first; 00178 second = triple.second; 00179 third = triple.third; 00180 00181 return *this; 00182 } 00183 00184 template <typename T1, typename T2, typename T3> 00185 BALL_INLINE 00186 void Triple<T1, T2, T3>::get(T1& t1, T2& t2, T3& t3) 00187 const 00188 { 00189 t1 = first; 00190 t2 = second; 00191 t3 = third; 00192 } 00193 00194 template <typename T1, typename T2, typename T3> 00195 BALL_INLINE 00196 bool Triple<T1, T2, T3>::operator == (const Triple& triple) 00197 const 00198 { 00199 return (first == triple.first 00200 && second == triple.second 00201 && third == triple.third); 00202 } 00203 00204 template <typename T1, typename T2, typename T3> 00205 BALL_INLINE 00206 bool Triple<T1, T2, T3>::operator != (const Triple& triple) 00207 const 00208 { 00209 return (first != triple.first 00210 || second != triple.second 00211 || third != triple.third); 00212 } 00213 00214 template <typename T1, typename T2, typename T3> 00215 BALL_INLINE 00216 void Triple<T1, T2, T3>::clear() 00217 { 00218 first = T1(); 00219 second = T2(); 00220 third = T3(); 00221 } 00222 00223 template <typename T1, typename T2, typename T3> 00224 BALL_INLINE 00225 bool Triple<T1, T2, T3>::operator < 00226 (const Triple<T1, T2, T3>& triple) const 00227 { 00228 return ((first < triple.first) 00229 || ((first == triple.first) && (second < triple.second)) 00230 || ((first == triple.first) && (second == triple.second) && (third < triple.third))); 00231 } 00232 00233 template <typename T1, typename T2, typename T3> 00234 BALL_INLINE 00235 bool Triple<T1, T2, T3>::operator <= 00236 (const Triple<T1, T2, T3>& triple) const 00237 { 00238 return ((first < triple.first) 00239 || ((first == triple.first) && (second < triple.second)) 00240 || ((first == triple.first) && (second == triple.second) && (third < triple.third)) 00241 || ((first == triple.first) && (second == triple.second) && (third == triple.third))); 00242 } 00243 00244 template <typename T1, typename T2, typename T3> 00245 BALL_INLINE 00246 bool Triple<T1, T2, T3>::operator >= 00247 (const Triple<T1, T2, T3>& triple) const 00248 { 00249 return ((first > triple.first) 00250 || ((first == triple.first) && (second > triple.second)) 00251 || ((first == triple.first) && (second == triple.second) && (third > triple.third)) 00252 || ((first == triple.first) && (second == triple.second) && (third == triple.third))); 00253 } 00254 00255 template <typename T1, typename T2, typename T3> 00256 BALL_INLINE 00257 bool Triple<T1, T2, T3>::operator > 00258 (const Triple<T1, T2, T3>& triple) const 00259 { 00260 return ((first > triple.first) 00261 || ((first == triple.first) && (second > triple.second)) 00262 || ((first == triple.first) && (second == triple.second) && (third > triple.third))); 00263 } 00264 } // namespace BALL 00265 00266 #endif // BALL_DATATYPE_TRIPLE_H