quadruplet.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #ifndef quadrupletINCLUDE
  2. #define quadrupletINCLUDE
  3. namespace NICE {
  4. /** @brief quadruplet extension, similar to pair */
  5. template <class T1, class T2, class T3, class T4>
  6. struct quadruplet
  7. {
  8. T1 first;
  9. T2 second;
  10. T3 third;
  11. T4 fourth;
  12. quadruplet ();
  13. quadruplet (const T1& x, const T2& y, const T3& z, const T4 & q)
  14. {
  15. first = x;
  16. second = y;
  17. third = z;
  18. fourth = q;
  19. }
  20. template <class U1, class U2, class U3, class U4>
  21. quadruplet (const quadruplet<U1, U2, U3, U4>& x) {
  22. first = x.first;
  23. second = x.second;
  24. third = x.third;
  25. fourth = x.fourth;
  26. }
  27. // Two keys are equivalent if the comparison function for the keys is false in both directions
  28. bool operator< ( const quadruplet<T1, T2, T3, T4> & t ) const
  29. {
  30. if (first < t.first) return true;
  31. else if ( first > t.first ) return false;
  32. else {
  33. if (second < t.second) return true;
  34. else if ( second > t.second ) return false;
  35. else {
  36. if (third < t.third) return true;
  37. else if (third > t.third) return false;
  38. else {
  39. if (fourth < t.fourth) return true;
  40. else return false;
  41. }
  42. }
  43. }
  44. }
  45. bool operator== ( const quadruplet<T1, T2, T3, T4> & t ) const
  46. {
  47. return ( (t.first == first) && (t.second == second) && (t.third == third)
  48. && (t.fourth == fourth) );
  49. }
  50. };
  51. }
  52. #endif