00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00030 
00031 
00032 #pragma once
00033 
00034 #ifndef _TRIPLET_H_
00035 #define _TRIPLET_H_
00036 
00037 #include <utility>
00038 
00039 namespace mbo
00040 {
00041 
00042 
00043 
00046 template<typename _Ty1, typename _Ty2, typename _Ty3>
00047 struct triplet: public std::pair<_Ty1, _Ty2>
00048 {
00049     typedef std::pair<_Ty1, _Ty2>     _Mybase;
00050     typedef triplet<_Ty1, _Ty2, _Ty3> _Myt;
00051     typedef _Ty3 third_type;
00052 
00053     triplet()
00054         : _Mybase()
00055         , third(_Ty3())
00056     {
00057     }
00058 
00059     triplet(const _Ty1& val1, const _Ty2& val2, const _Ty3& val3)
00060         : _Mybase(val1, val2)
00061         , third(val3)
00062     {
00063     }
00064 
00065     template<typename _O1, typename _O2, typename _O3>
00066     triplet(const triplet<_O1, _O2, _O3>& rhs)
00067         : _Mybase(rhs.first, rhs.second)
00068         , third(rhs.third)
00069     {
00070     }
00071 
00072     void swap(_Myt& rhs)
00073     {
00074         std::swap(first,  rhs.first);
00075         std::swap(second, rhs.second);
00076         std::swap(third,  rhs.third);
00077     }
00078 
00079     third_type   third;
00080 };
00081 
00082 template<typename _Ty1, typename _Ty2, typename _Ty3>
00083 inline bool __cdecl operator == (const triplet<_Ty1, _Ty2, _Ty3>& lhs, const triplet<_Ty1, _Ty2, _Ty3>& rhs)
00084 {
00085     return (lhs.first == rhs.first && lsh.second == rhs.second && lsh.third == rhs.third);
00086 }
00087 
00088 template<typename _Ty1, typename _Ty2, typename _Ty3>
00089 inline bool __cdecl operator != (const triplet<_Ty1, _Ty2, _Ty3>& lhs, const triplet<_Ty1, _Ty2, _Ty3>& rhs)
00090 {
00091     return (!(lhs == rhs));
00092 }
00093 
00094 template<typename _Ty1, typename _Ty2, typename _Ty3>
00095 inline bool __cdecl operator < (const triplet<_Ty1, _Ty2, _Ty3>& lhs, const triplet<_Ty1, _Ty2, _Ty3>& rhs)
00096 {
00097     return lhs::pair < rhs::pair  ||
00098         (!(rhs.first < lhs.first) && lhs.second < rhs.second) ||
00099         (!(rhs.first < lhs.first) && !(rhs.second < lhs.second) && lhs.third < rhs.third)
00100         ;
00101 }
00102 
00103 template<typename _Ty1, typename _Ty2, typename _Ty3>
00104 inline bool __cdecl operator > (const triplet<_Ty1, _Ty2, _Ty3>& lhs, const triplet<_Ty1, _Ty2, _Ty3>& rhs)
00105 {
00106     return (rhs < lhs);
00107 }
00108 
00109 template<typename _Ty1, typename _Ty2, typename _Ty3>
00110 inline bool __cdecl operator <= (const triplet<_Ty1, _Ty2, _Ty3>& lhs, const triplet<_Ty1, _Ty2, _Ty3>& rhs)
00111 {
00112     return (!(rhs < lhs));
00113 }
00114 
00115 template<typename _Ty1, typename _Ty2, typename _Ty3>
00116 inline bool __cdecl operator >= (const triplet<_Ty1, _Ty2, _Ty3>& lhs, const triplet<_Ty1, _Ty2, _Ty3>& rhs)
00117 {
00118     return (!(lhs < rhs));
00119 }
00120 
00121 template<typename _Ty1, typename _Ty2, typename _Ty3>
00122 inline triplet<_Ty1, _Ty2, _Ty3> __cdecl make_triplet(_Ty1 val1, _Ty2 val2, _Ty3 val3)
00123 {
00124     return (triplet<_Ty1, _Ty2, _Ty3>(val1, val2, val3));
00125 }
00126 
00127 template<typename _Ty1, typename _Ty2, typename _Ty3>
00128 inline void swap(triplet<_Ty1, _Ty2, _Ty3>& lhs, triplet<_Ty1, _Ty2, _Ty3>& rhs)
00129 {
00130     lhs.swap(rhs);
00131 }
00132 
00133 } 
00134 
00135 #endif // _TRIPLET_H_