Documentation review.
2 * lemon/bits/extended_pair.h - Part of LEMON, a generic C++ optimization library
4 * Copyright (C) 2005 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
5 * (Egervary Research Group on Combinatorial Optimization, EGRES).
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.
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
17 #ifndef LEMON_EXTENDED_PAIR_H
18 #define LEMON_EXTENDED_PAIR_H
22 ///\brief A more customizable pair type than std::pair.
26 /// \brief A more customizable pair type than std::pair.
28 /// This type is a customizable pair type. The main goal
29 /// is that the constructor's parameter type does not depend
30 /// on the stored data type. This way it is possible to store
31 /// references in the extended_pair.
34 /// typedef extended_pair<int&, int&, char&, char&> ICPair;
36 /// // like a real reference to an std::pair<int, char>
37 /// // but the pair does not exist
41 /// \param T1 The type of first.
42 /// \param A1 The parameter type for first.
43 /// \param T2 The type of second.
44 /// \param A2 The parameter type for second.
45 template <typename T1, typename A1, typename T2, typename A2>
46 struct extended_pair {
47 /// \brief The type of first.
49 /// The type of first.
50 typedef T1 first_type;
51 /// \brief The type of second.
53 /// The type of second.
54 typedef T2 second_type;
56 /// \brief Default constructor.
58 /// Default constructor. It calls the default constructor of
60 extended_pair() : first(), second() {}
62 /// \brief Constructor.
65 extended_pair(A1 f, A2 s) : first(f), second(s) {}
67 /// \brief Template constructor.
69 /// Template constructor. It copies everything which has
70 /// \c first and \c second member.
72 extended_pair(const Pair& pair) : first(pair.first), second(pair.second) {}
74 /// \brief The first value
78 /// \brief The second value
84 /// \brief Equality operator
87 template <typename T1, typename T2,
88 typename LA1, typename LA2, typename RA1, typename RA2>
89 bool operator==(const extended_pair<T1, LA1, T2, LA2>& left,
90 const extended_pair<T1, RA1, T2, RA2>& right) {
91 return left.first == right.first && left.second == right.second;
94 /// \brief Inequality operator.
96 /// Inequality operator.
97 template <typename T1, typename T2,
98 typename LA1, typename LA2, typename RA1, typename RA2>
99 bool operator!=(const extended_pair<T1, LA1, T2, LA2>& left,
100 const extended_pair<T1, RA1, T2, RA2>& right) {
101 return !(left == right);
104 /// \brief Less operator.
107 template <typename T1, typename T2,
108 typename LA1, typename LA2, typename RA1, typename RA2>
109 bool operator<(const extended_pair<T1, LA1, T2, LA2>& left,
110 const extended_pair<T1, RA1, T2, RA2>& right) {
111 return left.first < right.first ||
112 (!(right.first<left.first) && left.second < right.second);
115 /// \brief Greater operator.
117 /// Greater operator.
118 template <typename T1, typename T2,
119 typename LA1, typename LA2, typename RA1, typename RA2>
120 bool operator>(const extended_pair<T1, LA1, T2, LA2>& left,
121 const extended_pair<T1, RA1, T2, RA2>& right) {
125 /// \brief Less or equal operator.
127 /// Less or equal operator.
128 template <typename T1, typename T2,
129 typename LA1, typename LA2, typename RA1, typename RA2>
130 bool operator<=(const extended_pair<T1, LA1, T2, LA2>& left,
131 const extended_pair<T1, RA1, T2, RA2>& right) {
132 return !(right > left);
135 /// \brief Greater or equal operator.
137 /// Greater or equal operator.
138 template <typename T1, typename T2,
139 typename LA1, typename LA2, typename RA1, typename RA2>
140 bool operator>=(const extended_pair<T1, LA1, T2, LA2>& left,
141 const extended_pair<T1, RA1, T2, RA2>& right) {
142 return !(right < left);