src/lemon/extended_pair.h
author deba
Fri, 04 Mar 2005 17:16:01 +0000
changeset 1192 aa4483befa56
parent 921 818510fa3d99
permissions -rw-r--r--
Adding GraphEdgeSet and GraphNodeSet classes to graph_utils.h.
     1 /* -*- C++ -*-
     2  * src/lemon/extended_pair.h - Part of LEMON, a generic C++ optimization library
     3  *
     4  * Copyright (C) 2005 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
     5  * (Egervary Combinatorial Optimization Research Group, EGRES).
     6  *
     7  * Permission to use, modify and distribute this software is granted
     8  * provided that this copyright notice appears in all copies. For
     9  * precise terms see the accompanying LICENSE file.
    10  *
    11  * This software is provided "AS IS" with no warranty of any kind,
    12  * express or implied, and with no claim as to its suitability for any
    13  * purpose.
    14  *
    15  */
    16 
    17 #ifndef LEMON_EXTENDED_PAIR_H
    18 #define LEMON_EXTENDED_PAIR_H
    19 
    20 template <typename T1, typename A1, typename T2, typename A2>
    21 struct extended_pair {
    22   typedef T1 first_type;
    23   typedef T2 second_type;
    24 
    25   extended_pair() : first(), second() {}
    26 
    27   extended_pair(A1 f, A2 s) : first(f), second(s) {}
    28 
    29   template <class Pair>
    30   extended_pair(const Pair& pair) : first(pair.first), second(pair.second) {}
    31 
    32   T1 first;
    33   T2 second;
    34 };
    35 
    36 template <typename T1, typename T2, 
    37 	  typename LA1, typename LA2, typename RA1, typename RA2>
    38 bool operator==(const extended_pair<T1, LA1, T2, LA2>& left, 
    39 		const extended_pair<T1, RA1, T2, RA2>& right) {
    40   return left.first == right.first && left.second == right.second;
    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  !(left == right);
    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 left.first < right.first || 
    55            (!(right.first<left.first) && left.second < right.second);
    56 }
    57 
    58 template <typename T1, typename T2, 
    59 	  typename LA1, typename LA2, typename RA1, typename RA2>
    60 bool operator>(const extended_pair<T1, LA1, T2, LA2>& left, 
    61 		const extended_pair<T1, RA1, T2, RA2>& right) {
    62   return right < left;
    63 }
    64 
    65 template <typename T1, typename T2, 
    66 	  typename LA1, typename LA2, typename RA1, typename RA2>
    67 bool operator<=(const extended_pair<T1, LA1, T2, LA2>& left, 
    68 		const extended_pair<T1, RA1, T2, RA2>& right) {
    69   return !(right > left);
    70 }
    71 
    72 template <typename T1, typename T2, 
    73 	  typename LA1, typename LA2, typename RA1, typename RA2>
    74 bool operator>=(const extended_pair<T1, LA1, T2, LA2>& left, 
    75 		const extended_pair<T1, RA1, T2, RA2>& right) {
    76   return !(right < left);
    77 }
    78 
    79 
    80 #endif