COIN-OR::LEMON - Graph Library

source: lemon-0.x/src/lemon/extended_pair.h @ 1192:aa4483befa56

Last change on this file since 1192:aa4483befa56 was 1164:80bb73097736, checked in by Alpar Juttner, 19 years ago

A year has passed again.

File size: 2.5 KB
Line 
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
20template <typename T1, typename A1, typename T2, typename A2>
21struct 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
36template <typename T1, typename T2,
37          typename LA1, typename LA2, typename RA1, typename RA2>
38bool 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
43template <typename T1, typename T2,
44          typename LA1, typename LA2, typename RA1, typename RA2>
45bool operator!=(const extended_pair<T1, LA1, T2, LA2>& left,
46                const extended_pair<T1, RA1, T2, RA2>& right) {
47  return  !(left == right);
48}
49
50template <typename T1, typename T2,
51          typename LA1, typename LA2, typename RA1, typename RA2>
52bool 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
58template <typename T1, typename T2,
59          typename LA1, typename LA2, typename RA1, typename RA2>
60bool operator>(const extended_pair<T1, LA1, T2, LA2>& left,
61                const extended_pair<T1, RA1, T2, RA2>& right) {
62  return right < left;
63}
64
65template <typename T1, typename T2,
66          typename LA1, typename LA2, typename RA1, typename RA2>
67bool operator<=(const extended_pair<T1, LA1, T2, LA2>& left,
68                const extended_pair<T1, RA1, T2, RA2>& right) {
69  return !(right > left);
70}
71
72template <typename T1, typename T2,
73          typename LA1, typename LA2, typename RA1, typename RA2>
74bool 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
Note: See TracBrowser for help on using the repository browser.