src/lemon/extended_pair.h
author deba
Thu, 11 Nov 2004 10:17:20 +0000
changeset 981 2e34b796d532
parent 906 17f31d280385
child 1164 80bb73097736
permissions -rw-r--r--
maxUndirEdgeId modified to maxId(UndirEdge)
maxEdgeId modified to maxId(Edge)
alpar@906
     1
/* -*- C++ -*-
alpar@921
     2
 * src/lemon/extended_pair.h - Part of LEMON, a generic C++ optimization library
alpar@906
     3
 *
alpar@906
     4
 * Copyright (C) 2004 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
alpar@906
     5
 * (Egervary Combinatorial Optimization Research Group, EGRES).
alpar@906
     6
 *
alpar@906
     7
 * Permission to use, modify and distribute this software is granted
alpar@906
     8
 * provided that this copyright notice appears in all copies. For
alpar@906
     9
 * precise terms see the accompanying LICENSE file.
alpar@906
    10
 *
alpar@906
    11
 * This software is provided "AS IS" with no warranty of any kind,
alpar@906
    12
 * express or implied, and with no claim as to its suitability for any
alpar@906
    13
 * purpose.
alpar@906
    14
 *
alpar@906
    15
 */
alpar@906
    16
alpar@921
    17
#ifndef LEMON_EXTENDED_PAIR_H
alpar@921
    18
#define LEMON_EXTENDED_PAIR_H
deba@782
    19
deba@782
    20
template <typename T1, typename A1, typename T2, typename A2>
deba@782
    21
struct extended_pair {
deba@782
    22
  typedef T1 first_type;
deba@782
    23
  typedef T2 second_type;
deba@782
    24
deba@782
    25
  extended_pair() : first(), second() {}
deba@782
    26
deba@782
    27
  extended_pair(A1 f, A2 s) : first(f), second(s) {}
deba@782
    28
deba@782
    29
  template <class Pair>
deba@782
    30
  extended_pair(const Pair& pair) : first(pair.first), second(pair.second) {}
deba@782
    31
deba@782
    32
  T1 first;
deba@782
    33
  T2 second;
deba@782
    34
};
deba@782
    35
deba@782
    36
template <typename T1, typename T2, 
deba@782
    37
	  typename LA1, typename LA2, typename RA1, typename RA2>
deba@782
    38
bool operator==(const extended_pair<T1, LA1, T2, LA2>& left, 
deba@782
    39
		const extended_pair<T1, RA1, T2, RA2>& right) {
deba@782
    40
  return left.first == right.first && left.second == right.second;
deba@782
    41
}
deba@782
    42
deba@782
    43
template <typename T1, typename T2, 
deba@782
    44
	  typename LA1, typename LA2, typename RA1, typename RA2>
deba@782
    45
bool operator!=(const extended_pair<T1, LA1, T2, LA2>& left, 
deba@782
    46
		const extended_pair<T1, RA1, T2, RA2>& right) {
deba@782
    47
  return  !(left == right);
deba@782
    48
}
deba@782
    49
deba@782
    50
template <typename T1, typename T2, 
deba@782
    51
	  typename LA1, typename LA2, typename RA1, typename RA2>
deba@782
    52
bool operator<(const extended_pair<T1, LA1, T2, LA2>& left, 
deba@782
    53
		const extended_pair<T1, RA1, T2, RA2>& right) {
deba@897
    54
  return left.first < right.first || 
deba@897
    55
           (!(right.first<left.first) && left.second < right.second);
deba@782
    56
}
deba@782
    57
deba@782
    58
template <typename T1, typename T2, 
deba@782
    59
	  typename LA1, typename LA2, typename RA1, typename RA2>
deba@782
    60
bool operator>(const extended_pair<T1, LA1, T2, LA2>& left, 
deba@782
    61
		const extended_pair<T1, RA1, T2, RA2>& right) {
deba@782
    62
  return right < left;
deba@782
    63
}
deba@782
    64
deba@782
    65
template <typename T1, typename T2, 
deba@782
    66
	  typename LA1, typename LA2, typename RA1, typename RA2>
deba@782
    67
bool operator<=(const extended_pair<T1, LA1, T2, LA2>& left, 
deba@782
    68
		const extended_pair<T1, RA1, T2, RA2>& right) {
deba@782
    69
  return !(right > left);
deba@782
    70
}
deba@782
    71
deba@782
    72
template <typename T1, typename T2, 
deba@782
    73
	  typename LA1, typename LA2, typename RA1, typename RA2>
deba@782
    74
bool operator>=(const extended_pair<T1, LA1, T2, LA2>& left, 
deba@782
    75
		const extended_pair<T1, RA1, T2, RA2>& right) {
deba@782
    76
  return !(right < left);
deba@782
    77
}
deba@782
    78
deba@782
    79
deba@782
    80
#endif