1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/src/lemon/extended_pair.h Wed Sep 29 15:30:04 2004 +0000
1.3 @@ -0,0 +1,80 @@
1.4 +/* -*- C++ -*-
1.5 + * src/lemon/extended_pair.h - Part of LEMON, a generic C++ optimization library
1.6 + *
1.7 + * Copyright (C) 2004 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
1.8 + * (Egervary Combinatorial Optimization Research Group, EGRES).
1.9 + *
1.10 + * Permission to use, modify and distribute this software is granted
1.11 + * provided that this copyright notice appears in all copies. For
1.12 + * precise terms see the accompanying LICENSE file.
1.13 + *
1.14 + * This software is provided "AS IS" with no warranty of any kind,
1.15 + * express or implied, and with no claim as to its suitability for any
1.16 + * purpose.
1.17 + *
1.18 + */
1.19 +
1.20 +#ifndef LEMON_EXTENDED_PAIR_H
1.21 +#define LEMON_EXTENDED_PAIR_H
1.22 +
1.23 +template <typename T1, typename A1, typename T2, typename A2>
1.24 +struct extended_pair {
1.25 + typedef T1 first_type;
1.26 + typedef T2 second_type;
1.27 +
1.28 + extended_pair() : first(), second() {}
1.29 +
1.30 + extended_pair(A1 f, A2 s) : first(f), second(s) {}
1.31 +
1.32 + template <class Pair>
1.33 + extended_pair(const Pair& pair) : first(pair.first), second(pair.second) {}
1.34 +
1.35 + T1 first;
1.36 + T2 second;
1.37 +};
1.38 +
1.39 +template <typename T1, typename T2,
1.40 + typename LA1, typename LA2, typename RA1, typename RA2>
1.41 +bool operator==(const extended_pair<T1, LA1, T2, LA2>& left,
1.42 + const extended_pair<T1, RA1, T2, RA2>& right) {
1.43 + return left.first == right.first && left.second == right.second;
1.44 +}
1.45 +
1.46 +template <typename T1, typename T2,
1.47 + typename LA1, typename LA2, typename RA1, typename RA2>
1.48 +bool operator!=(const extended_pair<T1, LA1, T2, LA2>& left,
1.49 + const extended_pair<T1, RA1, T2, RA2>& right) {
1.50 + return !(left == right);
1.51 +}
1.52 +
1.53 +template <typename T1, typename T2,
1.54 + typename LA1, typename LA2, typename RA1, typename RA2>
1.55 +bool operator<(const extended_pair<T1, LA1, T2, LA2>& left,
1.56 + const extended_pair<T1, RA1, T2, RA2>& right) {
1.57 + return left.first < right.first ||
1.58 + (!(right.first<left.first) && left.second < right.second);
1.59 +}
1.60 +
1.61 +template <typename T1, typename T2,
1.62 + typename LA1, typename LA2, typename RA1, typename RA2>
1.63 +bool operator>(const extended_pair<T1, LA1, T2, LA2>& left,
1.64 + const extended_pair<T1, RA1, T2, RA2>& right) {
1.65 + return right < left;
1.66 +}
1.67 +
1.68 +template <typename T1, typename T2,
1.69 + typename LA1, typename LA2, typename RA1, typename RA2>
1.70 +bool operator<=(const extended_pair<T1, LA1, T2, LA2>& left,
1.71 + const extended_pair<T1, RA1, T2, RA2>& right) {
1.72 + return !(right > left);
1.73 +}
1.74 +
1.75 +template <typename T1, typename T2,
1.76 + typename LA1, typename LA2, typename RA1, typename RA2>
1.77 +bool operator>=(const extended_pair<T1, LA1, T2, LA2>& left,
1.78 + const extended_pair<T1, RA1, T2, RA2>& right) {
1.79 + return !(right < left);
1.80 +}
1.81 +
1.82 +
1.83 +#endif