00001
00002
00008 #if !defined(__ads_Triplet_h__)
00009 #define __ads_Triplet_h__
00010
00011 #include "../defs.h"
00012
00013 BEGIN_NAMESPACE_ADS
00014
00016 template<typename T1, typename T2, typename T3>
00017 struct Triplet {
00019 typedef T1 first_type;
00021 typedef T2 second_type;
00023 typedef T3 third_type;
00024
00026 first_type first;
00028 second_type second;
00030 third_type third;
00031
00033
00036 Triplet() :
00037 first(),
00038 second(),
00039 third()
00040 {}
00041
00043 Triplet(const first_type& a, const second_type& b, const third_type& c) :
00044 first(a),
00045 second(b),
00046 third(c)
00047 {}
00048
00050 template<typename U1, typename U2, typename U3>
00051 Triplet(const Triplet<U1,U2,U3>& x) :
00052 first(x.first),
00053 second(x.second),
00054 third(x.third)
00055 {}
00056 };
00057
00059 template<typename T1, typename T2, typename T3>
00060 inline
00061 bool
00062 operator==(const Triplet<T1,T2,T3>& x, const Triplet<T1,T2,T3>& y) {
00063 return x.first == y.first && x.second == y.second && x.third == y.third;
00064 }
00065
00067 template<typename T1, typename T2, typename T3>
00068 inline
00069 bool
00070 operator<(const Triplet<T1,T2,T3>& x, const Triplet<T1,T2,T3>& y) {
00071 return x.first < y.first ||
00072 (! (y.first < x.first) && x.second < y.second) ||
00073 (! (y.first < x.first) && ! (y.second < x.second) &&
00074 x.third < y.third);
00075 }
00076
00078 template<typename T1, typename T2, typename T3>
00079 inline
00080 bool
00081 operator!=(const Triplet<T1,T2,T3>& x, const Triplet<T1,T2,T3>& y) {
00082 return !(x == y);
00083 }
00084
00086 template<typename T1, typename T2, typename T3>
00087 inline
00088 bool
00089 operator>(const Triplet<T1,T2,T3>& x, const Triplet<T1,T2,T3>& y) {
00090 return y < x;
00091 }
00092
00094 template<typename T1, typename T2, typename T3>
00095 inline
00096 bool
00097 operator<=(const Triplet<T1,T2,T3>& x, const Triplet<T1,T2,T3>& y) {
00098 return !(y < x);
00099 }
00100
00102 template<typename T1, typename T2, typename T3>
00103 inline
00104 bool
00105 operator>=(const Triplet<T1,T2,T3>& x, const Triplet<T1,T2,T3>& y) {
00106 return !(x < y);
00107 }
00108
00110
00117 template<typename T1, typename T2, typename T3>
00118 inline
00119 Triplet<T1,T2,T3>
00120 makeTriplet(const T1& x, const T2& y, const T3& z) {
00121 return Triplet<T1,T2,T3>(x, y, z);
00122 }
00123
00124 END_NAMESPACE_ADS
00125
00126 #endif