src/work/deba/extended_pair.h
changeset 901 69a8e672acb1
parent 702 4207f82a1778
equal deleted inserted replaced
0:423e0835f286 1:06399a43d7b8
       
     1 // -*- c++ -*-
     1 #ifndef EXTENDED_PAIR_H
     2 #ifndef EXTENDED_PAIR_H
     2 #define EXTENDED_PAIR_H
     3 #define EXTENDED_PAIR_H
     3 
     4 
     4 template <typename T1, typename A1, typename T2, typename A2>
     5 template <typename T1, typename A1, typename T2, typename A2>
     5 struct extended_pair {
     6 struct extended_pair {
     6   typedef T1 first_type;
     7   typedef T1 first_type;
     7   typedef T2 second_type;
     8   typedef T2 second_type;
     8 
     9 
       
    10   extended_pair() : first(), second() {}
       
    11 
     9   extended_pair(A1 f, A2 s) : first(f), second(s) {}
    12   extended_pair(A1 f, A2 s) : first(f), second(s) {}
       
    13 
       
    14   template <class Pair>
       
    15   extended_pair(const Pair& pair) : first(pair.first), second(pair.second) {}
    10 
    16 
    11   T1 first;
    17   T1 first;
    12   T2 second;
    18   T2 second;
    13 };
    19 };
    14 
    20 
       
    21 template <typename T1, typename T2, 
       
    22 	  typename LA1, typename LA2, typename RA1, typename RA2>
       
    23 bool operator==(const extended_pair<T1, LA1, T2, LA2>& left, 
       
    24 		const extended_pair<T1, RA1, T2, RA2>& right) {
       
    25   return left.first == right.first && left.second == right.second;
       
    26 }
       
    27 
       
    28 template <typename T1, typename T2, 
       
    29 	  typename LA1, typename LA2, typename RA1, typename RA2>
       
    30 bool operator!=(const extended_pair<T1, LA1, T2, LA2>& left, 
       
    31 		const extended_pair<T1, RA1, T2, RA2>& right) {
       
    32   return  !(left == right);
       
    33 }
       
    34 
       
    35 template <typename T1, typename T2, 
       
    36 	  typename LA1, typename LA2, typename RA1, typename RA2>
       
    37 bool operator<(const extended_pair<T1, LA1, T2, LA2>& left, 
       
    38 		const extended_pair<T1, RA1, T2, RA2>& right) {
       
    39   if (left.first == right.first) return left.second == right.second;
       
    40   return left.first < right.first;
       
    41 }
       
    42 
       
    43 template <typename T1, typename T2, 
       
    44 	  typename LA1, typename LA2, typename RA1, typename RA2>
       
    45 bool operator>(const extended_pair<T1, LA1, T2, LA2>& left, 
       
    46 		const extended_pair<T1, RA1, T2, RA2>& right) {
       
    47   return right < left;
       
    48 }
       
    49 
       
    50 template <typename T1, typename T2, 
       
    51 	  typename LA1, typename LA2, typename RA1, typename RA2>
       
    52 bool operator<=(const extended_pair<T1, LA1, T2, LA2>& left, 
       
    53 		const extended_pair<T1, RA1, T2, RA2>& right) {
       
    54   return !(right > left);
       
    55 }
       
    56 
       
    57 template <typename T1, typename T2, 
       
    58 	  typename LA1, typename LA2, typename RA1, typename RA2>
       
    59 bool operator>=(const extended_pair<T1, LA1, T2, LA2>& left, 
       
    60 		const extended_pair<T1, RA1, T2, RA2>& right) {
       
    61   return !(right < left);
       
    62 }
       
    63 
       
    64 
    15 #endif
    65 #endif