extended_pair.h

00001 /* -*- C++ -*- 00002 * src/lemon/extended_pair.h - Part of LEMON, a generic C++ optimization library 00003 * 00004 * Copyright (C) 2004 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 00005 * (Egervary Combinatorial Optimization Research Group, EGRES). 00006 * 00007 * Permission to use, modify and distribute this software is granted 00008 * provided that this copyright notice appears in all copies. For 00009 * precise terms see the accompanying LICENSE file. 00010 * 00011 * This software is provided "AS IS" with no warranty of any kind, 00012 * express or implied, and with no claim as to its suitability for any 00013 * purpose. 00014 * 00015 */ 00016 00017 #ifndef LEMON_EXTENDED_PAIR_H 00018 #define LEMON_EXTENDED_PAIR_H 00019 00020 template <typename T1, typename A1, typename T2, typename A2> 00021 struct extended_pair { 00022 typedef T1 first_type; 00023 typedef T2 second_type; 00024 00025 extended_pair() : first(), second() {} 00026 00027 extended_pair(A1 f, A2 s) : first(f), second(s) {} 00028 00029 template <class Pair> 00030 extended_pair(const Pair& pair) : first(pair.first), second(pair.second) {} 00031 00032 T1 first; 00033 T2 second; 00034 }; 00035 00036 template <typename T1, typename T2, 00037 typename LA1, typename LA2, typename RA1, typename RA2> 00038 bool operator==(const extended_pair<T1, LA1, T2, LA2>& left, 00039 const extended_pair<T1, RA1, T2, RA2>& right) { 00040 return left.first == right.first && left.second == right.second; 00041 } 00042 00043 template <typename T1, typename T2, 00044 typename LA1, typename LA2, typename RA1, typename RA2> 00045 bool operator!=(const extended_pair<T1, LA1, T2, LA2>& left, 00046 const extended_pair<T1, RA1, T2, RA2>& right) { 00047 return !(left == right); 00048 } 00049 00050 template <typename T1, typename T2, 00051 typename LA1, typename LA2, typename RA1, typename RA2> 00052 bool operator<(const extended_pair<T1, LA1, T2, LA2>& left, 00053 const extended_pair<T1, RA1, T2, RA2>& right) { 00054 return left.first < right.first || 00055 (!(right.first<left.first) && left.second < right.second); 00056 } 00057 00058 template <typename T1, typename T2, 00059 typename LA1, typename LA2, typename RA1, typename RA2> 00060 bool operator>(const extended_pair<T1, LA1, T2, LA2>& left, 00061 const extended_pair<T1, RA1, T2, RA2>& right) { 00062 return right < left; 00063 } 00064 00065 template <typename T1, typename T2, 00066 typename LA1, typename LA2, typename RA1, typename RA2> 00067 bool operator<=(const extended_pair<T1, LA1, T2, LA2>& left, 00068 const extended_pair<T1, RA1, T2, RA2>& right) { 00069 return !(right > left); 00070 } 00071 00072 template <typename T1, typename T2, 00073 typename LA1, typename LA2, typename RA1, typename RA2> 00074 bool operator>=(const extended_pair<T1, LA1, T2, LA2>& left, 00075 const extended_pair<T1, RA1, T2, RA2>& right) { 00076 return !(right < left); 00077 } 00078 00079 00080 #endif

Generated on Thu Sep 30 12:18:33 2004 for LEMON by doxygen 1.3.8