00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #ifndef SUNDANCE_ORDEREDTUPLE_H
00032 #define SUNDANCE_ORDEREDTUPLE_H
00033
00034 #include "SundanceDefs.hpp"
00035
00036
00037 #ifndef DOXYGEN_DEVELOPER_ONLY
00038
00039 namespace Sundance
00040 {
00041 using namespace Teuchos;
00042
00043
00044
00045
00046
00047 template<class A, class B>
00048 class OrderedPair
00049 {
00050 public:
00051
00052 OrderedPair(const A& _a, const B& _b)
00053 : a_(_a), b_(_b) {;}
00054
00055
00056 inline bool operator<(const OrderedPair<A, B>& other) const
00057 {
00058 if ( a_ < other.a_ )
00059 {
00060 return true;
00061 }
00062 if ( other.a_ < a_)
00063 {
00064 return false;
00065 }
00066
00067 bool rtn = b_ < other.b_;
00068 return rtn;
00069 }
00070
00071
00072 const A& first() const {return a_;}
00073
00074
00075 const B& second() const {return b_;}
00076
00077 private:
00078 A a_;
00079 B b_;
00080 };
00081
00082
00083 template<class A, class B, class C>
00084 class OrderedTriple : public OrderedPair<A, OrderedPair<B, C> >
00085 {
00086 public:
00087
00088 OrderedTriple(const A& _a, const B& _b, const C& _c)
00089 : OrderedPair<A, OrderedPair<B, C> >(_a, OrderedPair<B,C>(_b,_c))
00090 {;}
00091
00092 const A& a() const {return this->first();}
00093
00094 const B& b() const {return this->second().first();}
00095
00096 const C& c() const {return this->second().second();}
00097 };
00098
00099
00100 template<class A, class B, class C, class D>
00101 class OrderedQuartet : public OrderedPair<A, OrderedTriple<B, C, D> >
00102 {
00103 public:
00104
00105 OrderedQuartet(const A& _a, const B& _b, const C& _c, const D& _d)
00106 : OrderedPair<A, OrderedTriple<B, C, D> >(_a, OrderedTriple<B,C,D>(_b,_c,_d))
00107 {;}
00108
00109 const A& a() const {return this->first();}
00110 const B& b() const {return this->second().first();}
00111 const C& c() const {return this->second().second().first();}
00112 const D& d() const {return this->second().second().second();}
00113 };
00114
00115
00116 template <class A, class B>
00117 inline std::ostream& operator<<(std::ostream& os, const OrderedPair<A,B>& p)
00118 {
00119 os << "{" << p.first() << ", " << p.second() << "}";
00120 return os;
00121 }
00122
00123 }
00124
00125
00126 #endif
00127 #endif