src/work/deba/extended_pair.h
author marci
Fri, 01 Oct 2004 11:31:03 +0000
changeset 933 1b7c88fbb950
parent 702 4207f82a1778
permissions -rw-r--r--
NodeSubGraphWrapper, test, and ducumentation modifications.
deba@703
     1
// -*- c++ -*-
deba@702
     2
#ifndef EXTENDED_PAIR_H
deba@702
     3
#define EXTENDED_PAIR_H
deba@702
     4
deba@702
     5
template <typename T1, typename A1, typename T2, typename A2>
deba@702
     6
struct extended_pair {
deba@702
     7
  typedef T1 first_type;
deba@702
     8
  typedef T2 second_type;
deba@702
     9
deba@703
    10
  extended_pair() : first(), second() {}
deba@703
    11
deba@702
    12
  extended_pair(A1 f, A2 s) : first(f), second(s) {}
deba@702
    13
deba@703
    14
  template <class Pair>
deba@703
    15
  extended_pair(const Pair& pair) : first(pair.first), second(pair.second) {}
deba@703
    16
deba@702
    17
  T1 first;
deba@702
    18
  T2 second;
deba@702
    19
};
deba@702
    20
deba@703
    21
template <typename T1, typename T2, 
deba@703
    22
	  typename LA1, typename LA2, typename RA1, typename RA2>
deba@703
    23
bool operator==(const extended_pair<T1, LA1, T2, LA2>& left, 
deba@703
    24
		const extended_pair<T1, RA1, T2, RA2>& right) {
deba@703
    25
  return left.first == right.first && left.second == right.second;
deba@703
    26
}
deba@703
    27
deba@703
    28
template <typename T1, typename T2, 
deba@703
    29
	  typename LA1, typename LA2, typename RA1, typename RA2>
deba@703
    30
bool operator!=(const extended_pair<T1, LA1, T2, LA2>& left, 
deba@703
    31
		const extended_pair<T1, RA1, T2, RA2>& right) {
deba@703
    32
  return  !(left == right);
deba@703
    33
}
deba@703
    34
deba@703
    35
template <typename T1, typename T2, 
deba@703
    36
	  typename LA1, typename LA2, typename RA1, typename RA2>
deba@703
    37
bool operator<(const extended_pair<T1, LA1, T2, LA2>& left, 
deba@703
    38
		const extended_pair<T1, RA1, T2, RA2>& right) {
deba@703
    39
  if (left.first == right.first) return left.second == right.second;
deba@703
    40
  return left.first < right.first;
deba@703
    41
}
deba@703
    42
deba@703
    43
template <typename T1, typename T2, 
deba@703
    44
	  typename LA1, typename LA2, typename RA1, typename RA2>
deba@703
    45
bool operator>(const extended_pair<T1, LA1, T2, LA2>& left, 
deba@703
    46
		const extended_pair<T1, RA1, T2, RA2>& right) {
deba@703
    47
  return right < left;
deba@703
    48
}
deba@703
    49
deba@703
    50
template <typename T1, typename T2, 
deba@703
    51
	  typename LA1, typename LA2, typename RA1, typename RA2>
deba@703
    52
bool operator<=(const extended_pair<T1, LA1, T2, LA2>& left, 
deba@703
    53
		const extended_pair<T1, RA1, T2, RA2>& right) {
deba@703
    54
  return !(right > left);
deba@703
    55
}
deba@703
    56
deba@703
    57
template <typename T1, typename T2, 
deba@703
    58
	  typename LA1, typename LA2, typename RA1, typename RA2>
deba@703
    59
bool operator>=(const extended_pair<T1, LA1, T2, LA2>& left, 
deba@703
    60
		const extended_pair<T1, RA1, T2, RA2>& right) {
deba@703
    61
  return !(right < left);
deba@703
    62
}
deba@703
    63
deba@703
    64
deba@702
    65
#endif