/* -*- C++ -*- * src/lemon/sym_map.h - Part of LEMON, a generic C++ optimization library * * Copyright (C) 2004 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport * (Egervary Combinatorial Optimization Research Group, 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_SYM_MAP_H #define LEMON_SYM_MAP_H ///\ingroup graphmaps ///\file ///\brief Graph maps that construates and destruates ///their elements dynamically. namespace lemon { /// \addtogroup graphmaps /// @{ /** The SymEdgeIt is wrapper class for the EdgeIt. It can be used to * iterate on the symmetric maps when all of the edge - reverse edge pair * has different parity. */ template class SymEdgeIt : public EdgeIt { public: /** Default constructor. */ SymEdgeIt() : EdgeIt() {} /** Graph initialized constructor. */ SymEdgeIt(const Graph& graph) : EdgeIt(graph) { while ( (EdgeIt::n & 1) && EdgeIt::n != -1) { EdgeIt::operator++(); } } /** Creating invelid SymEdgeIt. */ SymEdgeIt(Invalid invalid) : EdgeIt(invalid) {} /** SymEdgeIt from the given Edge. */ SymEdgeIt(const Graph& graph, const Edge& edge) : EdgeIt(graph, edge) { while ( (EdgeIt::n & 1) && EdgeIt::n != -1) { EdgeIt::operator++(); } } /** Increase operator. */ SymEdgeIt& operator++() { EdgeIt::operator++(); while ( (EdgeIt::n & 1) && EdgeIt::n != -1) { EdgeIt::operator++(); } return *this; } }; /** The SymMap template class is graph map structure what * wraps an other map structure to use as symmetric map structure. * * The template parameter is the MapRegistry that the maps * will belong to and the ValueType. */ template