deba@703: // -*- c++ -*- deba@702: #ifndef EXTENDED_PAIR_H deba@702: #define EXTENDED_PAIR_H deba@702: deba@702: template <typename T1, typename A1, typename T2, typename A2> deba@702: struct extended_pair { deba@702: typedef T1 first_type; deba@702: typedef T2 second_type; deba@702: deba@703: extended_pair() : first(), second() {} deba@703: deba@702: extended_pair(A1 f, A2 s) : first(f), second(s) {} deba@702: deba@703: template <class Pair> deba@703: extended_pair(const Pair& pair) : first(pair.first), second(pair.second) {} deba@703: deba@702: T1 first; deba@702: T2 second; deba@702: }; deba@702: deba@703: template <typename T1, typename T2, deba@703: typename LA1, typename LA2, typename RA1, typename RA2> deba@703: bool operator==(const extended_pair<T1, LA1, T2, LA2>& left, deba@703: const extended_pair<T1, RA1, T2, RA2>& right) { deba@703: return left.first == right.first && left.second == right.second; deba@703: } deba@703: deba@703: template <typename T1, typename T2, deba@703: typename LA1, typename LA2, typename RA1, typename RA2> deba@703: bool operator!=(const extended_pair<T1, LA1, T2, LA2>& left, deba@703: const extended_pair<T1, RA1, T2, RA2>& right) { deba@703: return !(left == right); deba@703: } deba@703: deba@703: template <typename T1, typename T2, deba@703: typename LA1, typename LA2, typename RA1, typename RA2> deba@703: bool operator<(const extended_pair<T1, LA1, T2, LA2>& left, deba@703: const extended_pair<T1, RA1, T2, RA2>& right) { deba@703: if (left.first == right.first) return left.second == right.second; deba@703: return left.first < right.first; deba@703: } deba@703: deba@703: template <typename T1, typename T2, deba@703: typename LA1, typename LA2, typename RA1, typename RA2> deba@703: bool operator>(const extended_pair<T1, LA1, T2, LA2>& left, deba@703: const extended_pair<T1, RA1, T2, RA2>& right) { deba@703: return right < left; deba@703: } deba@703: deba@703: template <typename T1, typename T2, deba@703: typename LA1, typename LA2, typename RA1, typename RA2> deba@703: bool operator<=(const extended_pair<T1, LA1, T2, LA2>& left, deba@703: const extended_pair<T1, RA1, T2, RA2>& right) { deba@703: return !(right > left); deba@703: } deba@703: deba@703: template <typename T1, typename T2, deba@703: typename LA1, typename LA2, typename RA1, typename RA2> deba@703: bool operator>=(const extended_pair<T1, LA1, T2, LA2>& left, deba@703: const extended_pair<T1, RA1, T2, RA2>& right) { deba@703: return !(right < left); deba@703: } deba@703: deba@703: deba@702: #endif