COIN-OR::LEMON - Graph Library

Changeset 980:0f1044b7a3af in lemon-0.x for src/lemon/array_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/array_map.h

    r979 r980  
    4545            typename _Item,
    4646            typename _ItemIt,
    47             typename _IdMap,
    4847            typename _Value>
    4948  class ArrayMap : public AlterationObserverRegistry<_Item>::ObserverBase {
     
    6160    /// The iterator to iterate on the keys.
    6261    typedef _ItemIt KeyIt;
    63 
    64     typedef _IdMap IdMap;
    6562
    6663    typedef _Value Value;
     
    9592    /** Graph and Registry initialized map constructor.
    9693     */
    97     ArrayMap(const Graph& _g, Registry& _r) : graph(&_g) {
    98       attach(_r);
     94    ArrayMap(const Graph& _g) : graph(&_g) {
     95      attach(_g.getObserverRegistry(_Item()));
    9996      allocate_memory();
    10097      for (KeyIt it(*graph); it != INVALID; ++it) {
    101         int id = IdMap(*graph)[it];
     98        int id = graph->id(it);;
    10299        allocator.construct(&(values[id]), Value());
    103100      }                                                         
     
    108105    /// It constrates a map and initialize all of the the map.
    109106
    110     ArrayMap(const Graph& _g, Registry& _r, const Value& _v) : graph(&_g) {
    111       attach(_r);
     107    ArrayMap(const Graph& _g, const Value& _v) : graph(&_g) {
     108      attach(_g.getObserverRegistry(_Item()));
    112109      allocate_memory();
    113110      for (KeyIt it(*graph); it != INVALID; ++it) {
    114         int id = IdMap(*graph)[it];
     111        int id = graph->id(it);;
    115112        allocator.construct(&(values[id]), _v);
    116113      }                                                         
     
    127124      values = allocator.allocate(capacity);
    128125      for (KeyIt it(*graph); it != INVALID; ++it) {
    129         int id = IdMap(*graph)[it];
     126        int id = graph->id(it);;
    130127        allocator.construct(&(values[id]), copy.values[id]);
    131128      }
     
    155152
    156153      for (KeyIt it(*graph); it != INVALID; ++it) {
    157         int id = IdMap(*graph)[it];
     154        int id = graph->id(it);;
    158155        allocator.construct(&(values[id]), copy.values[id]);
    159156      }
     
    177174     */
    178175    ReferenceType operator[](const KeyType& key) {
    179       int id = IdMap(*graph)[key];
     176      int id = graph->id(key);
    180177      return values[id];
    181178    }
     
    186183     */
    187184    ConstReferenceType operator[](const KeyType& key) const {
    188       int id = IdMap(*graph)[key];
     185      int id = graph->id(key);
    189186      return values[id];
    190187    }
     
    200197     */
    201198    void add(const KeyType& key) {
    202       int id = IdMap(*graph)[key];
     199      int id = graph->id(key);
    203200      if (id >= capacity) {
    204201        int new_capacity = (capacity == 0 ? 1 : capacity);
     
    208205        Value* new_values = allocator.allocate(new_capacity);
    209206        for (KeyIt it(*graph); it != INVALID; ++it) {
    210           int jd = IdMap(*graph)[it];
     207          int jd = graph->id(it);;
    211208          if (id != jd) {
    212209            allocator.construct(&(new_values[jd]), values[jd]);
     
    224221     */
    225222    void erase(const KeyType& key) {
    226       int id = IdMap(*graph)[key];
     223      int id = graph->id(key);
    227224      allocator.destroy(&(values[id]));
    228225    }
     
    231228      allocate_memory();
    232229      for (KeyIt it(*graph); it != INVALID; ++it) {
    233         int id = IdMap(*graph)[it];
     230        int id = graph->id(it);;
    234231        allocator.construct(&(values[id]), Value());
    235232      }                                                         
     
    239236      if (capacity != 0) {
    240237        for (KeyIt it(*graph); it != INVALID; ++it) {
    241           int id = IdMap(*graph)[it];
     238          int id = graph->id(it);;
    242239          allocator.destroy(&(values[id]));
    243240        }                                                               
     
    303300     
    304301    void allocate_memory() {
    305       int max_id = IdMap(*graph).maxId();
     302      int max_id = graph->maxId(_Item());
    306303      if (max_id == -1) {
    307304        capacity = 0;
     
    344341    typedef typename Parent::Node Node;
    345342    typedef typename Parent::NodeIt NodeIt;
    346     typedef typename Parent::NodeIdMap NodeIdMap;
    347343    typedef typename Parent::NodeObserverRegistry NodeObserverRegistry;
    348344
    349345    typedef typename Parent::Edge Edge;
    350346    typedef typename Parent::EdgeIt EdgeIt;
    351     typedef typename Parent::EdgeIdMap EdgeIdMap;
    352347    typedef typename Parent::EdgeObserverRegistry EdgeObserverRegistry;
    353348
     
    355350
    356351    template <typename _Value>
    357     class NodeMap : public ArrayMap<Graph, Node, NodeIt, NodeIdMap, _Value> {
     352    class NodeMap : public ArrayMap<Graph, Node, NodeIt, _Value> {
    358353    public:
    359354      typedef ArrayMappableGraphExtender<_Base> Graph;
     
    361356      typedef typename Graph::Node Node;
    362357      typedef typename Graph::NodeIt NodeIt;
    363       typedef typename Graph::NodeIdMap NodeIdMap;
    364 
    365       typedef ArrayMap<Graph, Node, NodeIt, NodeIdMap, _Value> Parent;
     358
     359      typedef ArrayMap<Graph, Node, NodeIt, _Value> Parent;
    366360
    367361      //typedef typename Parent::Graph Graph;
     
    369363
    370364      NodeMap(const Graph& g)
    371         : Parent(g, g.getNodeObserverRegistry()) {}
     365        : Parent(g) {}
    372366      NodeMap(const Graph& g, const Value& v)
    373         : Parent(g, g.getNodeObserverRegistry(), v) {}
     367        : Parent(g, v) {}
    374368
    375369    };
    376370
    377371    template <typename _Value>
    378     class EdgeMap : public ArrayMap<Graph, Edge, EdgeIt, EdgeIdMap, _Value> {
     372    class EdgeMap : public ArrayMap<Graph, Edge, EdgeIt, _Value> {
    379373    public:
    380374      typedef ArrayMappableGraphExtender<_Base> Graph;
     
    382376      typedef typename Graph::Edge Edge;
    383377      typedef typename Graph::EdgeIt EdgeIt;
    384       typedef typename Graph::EdgeIdMap EdgeIdMap;
    385 
    386       typedef ArrayMap<Graph, Edge, EdgeIt, EdgeIdMap, _Value> Parent;
     378
     379      typedef ArrayMap<Graph, Edge, EdgeIt, _Value> Parent;
    387380
    388381      //typedef typename Parent::Graph Graph;
     
    390383
    391384      EdgeMap(const Graph& g)
    392         : Parent(g, g.getEdgeObserverRegistry()) {}
     385        : Parent(g) {}
    393386      EdgeMap(const Graph& g, const Value& v)
    394         : Parent(g, g.getEdgeObserverRegistry(), v) {}
     387        : Parent(g, v) {}
    395388
    396389    };
Note: See TracChangeset for help on using the changeset viewer.