triplet.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #ifndef TRIPLETINCLUDE
  2. #define TRIPLETINCLUDE
  3. namespace NICE {
  4. template <class T1, class T2, class T3>
  5. struct triplet
  6. {
  7. T1 first;
  8. T2 second;
  9. T3 third;
  10. triplet ();
  11. triplet (const T1& x, const T2& y, const T3& z)
  12. {
  13. first = x;
  14. second = y;
  15. third = z;
  16. }
  17. template <class U1, class U2, class U3>
  18. triplet (const triplet<U1, U2, U3>& x) {
  19. first = x.first;
  20. second = x.second;
  21. third = x.third;
  22. }
  23. // Two keys are equivalent if the comparison function for the keys is false in both directions
  24. bool operator< ( const triplet<T1, T2, T3> & t ) const
  25. {
  26. if (first < t.first) return true;
  27. else if ( first > t.first ) return false;
  28. else {
  29. if (second < t.second) return true;
  30. else if ( second > t.second ) return false;
  31. else {
  32. if (third < t.third) return true;
  33. else return false;
  34. }
  35. }
  36. }
  37. bool operator== ( const triplet<T1, T2, T3> & t ) const
  38. {
  39. return ( (t.first == first) && (t.second == second) && (t.third == third) );
  40. }
  41. };
  42. }
  43. #endif