quadruple.h

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