diff -r d8475431bbbb -r 8e85e6bbefdf src/lemon/bits/extended_pair.h --- a/src/lemon/bits/extended_pair.h Sat May 21 21:04:57 2005 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,146 +0,0 @@ -/* -*- C++ -*- - * src/lemon/bits/extended_pair.h - Part of LEMON, a generic C++ optimization library - * - * Copyright (C) 2005 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport - * (Egervary Research Group on Combinatorial Optimization, EGRES). - * - * Permission to use, modify and distribute this software is granted - * provided that this copyright notice appears in all copies. For - * precise terms see the accompanying LICENSE file. - * - * This software is provided "AS IS" with no warranty of any kind, - * express or implied, and with no claim as to its suitability for any - * purpose. - * - */ - -#ifndef LEMON_EXTENDED_PAIR_H -#define LEMON_EXTENDED_PAIR_H - -///\ingroup misc -///\file -///\brief A more customizable pair type than std::pair. - -namespace lemon { - - /// \brief A more customizable pair type than std::pair. - /// - /// This type is a customizable pair type. The main goal - /// is that the constructor's parameter type does not depend - /// on the stored data type. This way it is possible to store - /// references in the extended_pair. - /// \code - /// int a; char b; - /// typedef extended_pair ICPair; - /// ICPair p(a, b); - /// // like a real reference to an std::pair - /// // but the pair does not exist - /// p.first = 42; - /// p.second = '@'; - /// \endcode - /// \param T1 The type of first. - /// \param A1 The parameter type for first. - /// \param T2 The type of second. - /// \param A2 The parameter type for second. - template - struct extended_pair { - /// \brief The type of first. - /// - /// The type of first. - typedef T1 first_type; - /// \brief The type of second. - /// - /// The type of second. - typedef T2 second_type; - - /// \brief Default constructor. - /// - /// Default constructor. It calls the default constructor of - /// first and second. - extended_pair() : first(), second() {} - - /// \brief Constructor. - /// - /// Constructor. - extended_pair(A1 f, A2 s) : first(f), second(s) {} - - /// \brief Template constructor. - /// - /// Template constructor. It copies everything which has - /// \c first and \c second member. - template - extended_pair(const Pair& pair) : first(pair.first), second(pair.second) {} - - /// \brief The first value - /// - /// The first value - T1 first; - /// \brief The second value - /// - /// The second value - T2 second; - }; - - /// \brief Equality operator - /// - /// Equality operator - template - bool operator==(const extended_pair& left, - const extended_pair& right) { - return left.first == right.first && left.second == right.second; - } - - /// \brief Inequality operator. - /// - /// Inequality operator. - template - bool operator!=(const extended_pair& left, - const extended_pair& right) { - return !(left == right); - } - - /// \brief Less operator. - /// - /// Less operator. - template - bool operator<(const extended_pair& left, - const extended_pair& right) { - return left.first < right.first || - (!(right.first - bool operator>(const extended_pair& left, - const extended_pair& right) { - return right < left; - } - - /// \brief Less or equal operator. - /// - /// Less or equal operator. - template - bool operator<=(const extended_pair& left, - const extended_pair& right) { - return !(right > left); - } - - /// \brief Greater or equal operator. - /// - /// Greater or equal operator. - template - bool operator>=(const extended_pair& left, - const extended_pair& right) { - return !(right < left); - } - -} -#endif