COIN-OR::LEMON - Graph Library

Changeset 340:a2ce3c4780b7 in lemon-0.x for src/work/deba/edge_map_base.h


Ignore:
Timestamp:
04/16/04 15:42:03 (20 years ago)
Author:
Balazs Dezso
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@459
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/work/deba/edge_map_base.h

    r336 r340  
    22#define EDGE_MAP_BASE_H
    33
    4 template <class G, class K>
     4/**
     5        Template base class for implementing mapping on edges.
     6        \param The first template parameter is the Graph class. The Graph
     7                must have an \emp edge_maps member with \emp EdgeMapRegistry class.
     8        \param The second template parameter is the Edge type of the class.
     9       
     10*/
     11
     12template <typename G, typename K>
    513class EdgeMapBase {
    614public:
     
    917        typedef K KeyType;
    1018       
     19        /**
     20                Default constructor.
     21        */     
     22       
    1123        EdgeMapBase() : graph(0) {}
     24
     25        /**
     26                Simple constructor to register into a graph.
     27        */
     28       
    1229        EdgeMapBase(Graph& g) : graph(&g) {
    1330                graph->edge_maps.add(*this);
    1431        }
     32
     33        /**
     34                Copy constructor with registering into the map.
     35        */     
     36       
     37        EdgeMapBase(const EdgeMapBase& copy) : graph(copy.graph) {
     38                if (graph) {
     39                        graph->edge_maps.add(*this);
     40                }
     41        }
     42       
     43        /**
     44                Assign operator.
     45        */     
     46
     47        const EdgeMapBase& operator=(const EdgeMapBase& copy) {
     48                if (graph) {
     49                        graph.edge_maps.erase(*this);
     50                }
     51                graph = copy.graph;
     52                if (graph) {
     53                        graph->edge_maps.add(*this);
     54                }
     55               
     56        }
     57       
     58
     59        /**
     60                Destructor.
     61        */     
    1562
    1663        virtual ~EdgeMapBase() {
     
    2673        int graph_index;
    2774       
     75        /**
     76                Helper function to implement the default constructor in the subclasses.
     77        */
     78       
    2879        void init() {
    2980                for (Graph::EdgeIt it(g); g.valid(it); g.next(it)) {
     
    3182                }
    3283        }
     84       
     85        /**
     86                Helper function to implement the destructor in the subclasses.
     87        */
    3388       
    3489        void destroy() {
     
    3893        }
    3994       
     95        /**
     96                The add member function should be overloaded in the subclasses.
     97                \e Add extends the map with the new edge.
     98        */
     99       
    40100        virtual void add(const KeyType&) = 0;
     101       
     102        /**
     103                The erase member function should be overloaded in the subclasses.
     104                \e Erase removes the edge from the map.
     105        */
     106       
    41107        virtual void erase(const KeyType&) = 0;
     108       
     109        /**
     110                Exception class to throw at unsupported operation.
     111        */
     112       
     113        class NotSupportedOperationException {};
    42114
    43115        friend class Graph;
Note: See TracChangeset for help on using the changeset viewer.