COIN-OR::LEMON - Graph Library

Changeset 980:0f1044b7a3af in lemon-0.x for src/lemon/vector_map.h


Ignore:
Timestamp:
11/11/04 10:31:55 (19 years ago)
Author:
Balazs Dezso
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@1368
Message:

maxNodeId() and maxEdgeId() changed to maxId(Node) and maxId(Edge)
getNodeObserverRegistry() and getEdgeObserverRegistry() changed to
getObserverRegistry(Node) and getObserverRegistry(Edge)

IdMappableGraphExtender? erased

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/lemon/vector_map.h

    r979 r980  
    4747  template <typename _Graph,
    4848            typename _Item,
    49             typename _IdMap,
    5049            typename _Value>
    5150  class VectorMap : public AlterationObserverRegistry<_Item>::ObserverBase {
     
    5756    typedef _Item KeyType;
    5857    /// The id map type of the map.
    59     typedef _IdMap IdMap;
    60     /// The registry type of the map.
    6158    typedef AlterationObserverRegistry<_Item> Registry;
    6259    /// The value type of the map.
     
    9491    /// It adds all the items of the graph to the map.
    9592     
    96     VectorMap(const Graph& _g, Registry& _r) : graph(&_g) {
    97       attach(_r);
     93    VectorMap(const Graph& _g) : graph(&_g) {
     94      attach(_g.getObserverRegistry(_Item()));
    9895      build();
    9996    }
     
    104101    /// It adds all the items of the graph to the map.
    105102     
    106     VectorMap(const Graph& g, Registry& r, const Value& v) : graph(&g) {
    107       attach(r);
    108       container.resize(IdMap(*graph).maxId() + 1, v);
    109     }
    110 
    111     VectorMap(const VectorMap& copy) : graph(copy.getGraph()) {
    112       if (copy.attached()) {
    113         attach(*copy.getRegistry());
    114         container = copy.container;
     103    VectorMap(const Graph& _g, const Value& _v) : graph(&_g) {
     104      attach(_g.getObserverRegistry(_Item()));
     105      container.resize(graph->maxId(_Item()) + 1, _v);
     106    }
     107
     108    VectorMap(const VectorMap& _copy) : graph(_copy.getGraph()) {
     109      if (_copy.attached()) {
     110        attach(*_copy.getRegistry());
     111        container = _copy.container;
    115112      }
    116113    }
     
    155152     
    156153    ReferenceType operator[](const KeyType& key) {
    157       return container[IdMap(*graph)[key]];
     154      return container[graph->id(key)];
    158155    }
    159156               
     
    164161     
    165162    ConstReferenceType operator[](const KeyType& key) const {
    166       return container[IdMap(*graph)[key]];
     163      return container[graph->id(key)];
    167164    }
    168165
     
    183180     
    184181    void add(const KeyType& key) {
    185       int id = IdMap(*graph)[key];
     182      int id = graph->id(key);
    186183      if (id >= (int)container.size()) {
    187184        container.resize(id + 1);
     
    201198
    202199    void build() {
    203       container.resize(IdMap(*graph).maxId() + 1);
     200      container.resize(graph->maxId(_Item()) + 1);
    204201    }
    205202
     
    240237
    241238    template <typename _Value>
    242     class NodeMap : public VectorMap<Graph, Node, NodeIdMap, _Value> {
     239    class NodeMap : public VectorMap<Graph, Node, _Value> {
    243240    public:
    244241      typedef VectorMappableGraphExtender<_Base> Graph;
    245242
    246243      typedef typename Graph::Node Node;
    247       typedef typename Graph::NodeIdMap NodeIdMap;
    248 
    249       typedef VectorMap<Graph, Node, NodeIdMap, _Value> Parent;
     244
     245      typedef VectorMap<Graph, Node, _Value> Parent;
    250246
    251247      //typedef typename Parent::Graph Graph;
     
    253249
    254250      NodeMap(const Graph& g)
    255         : Parent(g, g.getNodeObserverRegistry()) {}
     251        : Parent(g) {}
    256252      NodeMap(const Graph& g, const Value& v)
    257         : Parent(g, g.getNodeObserverRegistry(), v) {}
     253        : Parent(g, v) {}
    258254
    259255    };
    260256
    261257    template <typename _Value>
    262     class EdgeMap : public VectorMap<Graph, Edge, EdgeIdMap, _Value> {
     258    class EdgeMap : public VectorMap<Graph, Edge, _Value> {
    263259    public:
    264260      typedef VectorMappableGraphExtender<_Base> Graph;
    265261
    266262      typedef typename Graph::Edge Edge;
    267       typedef typename Graph::EdgeIdMap EdgeIdMap;
    268 
    269       typedef VectorMap<Graph, Edge, EdgeIdMap, _Value> Parent;
     263
     264      typedef VectorMap<Graph, Edge, _Value> Parent;
    270265
    271266      //typedef typename Parent::Graph Graph;
     
    273268
    274269      EdgeMap(const Graph& g)
    275         : Parent(g, g.getEdgeObserverRegistry()) {}
     270        : Parent(g) {}
    276271      EdgeMap(const Graph& g, const Value& v)
    277         : Parent(g, g.getEdgeObserverRegistry(), v) {}
     272        : Parent(g, v) {}
    278273
    279274    };
Note: See TracChangeset for help on using the changeset viewer.