COIN-OR::LEMON - Graph Library

Changeset 209:765619b7cbb2 in lemon-1.2 for lemon/bits/vector_map.h


Ignore:
Timestamp:
07/13/08 20:51:02 (11 years ago)
Author:
Alpar Juttner <alpar@…>
Branch:
default
Phase:
public
Message:

Apply unify-sources.sh to the source tree

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lemon/bits/vector_map.h

    r157 r209  
    1 /* -*- C++ -*-
    2  *
    3  * This file is a part of LEMON, a generic C++ optimization library
     1/* -*- mode: C++; indent-tabs-mode: nil; -*-
     2 *
     3 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    55 * Copyright (C) 2003-2008
     
    5050  /// \todo Fix the doc: there is _Graph parameter instead of _Notifier.
    5151  template <typename _Graph, typename _Item, typename _Value>
    52   class VectorMap 
     52  class VectorMap
    5353    : public ItemSetTraits<_Graph, _Item>::ItemNotifier::ObserverBase {
    5454  private:
    55                
     55
    5656    /// The container type of the map.
    57     typedef std::vector<_Value> Container;     
     57    typedef std::vector<_Value> Container;
    5858
    5959  public:
    6060
    61     /// The graph type of the map. 
     61    /// The graph type of the map.
    6262    typedef _Graph Graph;
    6363    /// The item type of the map.
     
    9494    }
    9595
    96     /// \brief Constructor uses given value to initialize the map. 
    97     ///
    98     /// It constructs a map uses a given value to initialize the map. 
     96    /// \brief Constructor uses given value to initialize the map.
     97    ///
     98    /// It constructs a map uses a given value to initialize the map.
    9999    /// It adds all the items of the graph to the map.
    100100    VectorMap(const Graph& graph, const Value& value) {
     
    108108    VectorMap(const VectorMap& _copy) : Parent() {
    109109      if (_copy.attached()) {
    110         Parent::attach(*_copy.notifier());
    111         container = _copy.container;
     110        Parent::attach(*_copy.notifier());
     111        container = _copy.container;
    112112      }
    113113    }
     
    116116    ///
    117117    /// This operator assigns for each item in the map the
    118     /// value mapped to the same item in the copied map. 
     118    /// value mapped to the same item in the copied map.
    119119    /// The parameter map should be indiced with the same
    120120    /// itemset because this assign operator does not change
    121     /// the container of the map. 
     121    /// the container of the map.
    122122    VectorMap& operator=(const VectorMap& cmap) {
    123123      return operator=<VectorMap>(cmap);
     
    130130    /// concecpt and could be indiced by the current item set of
    131131    /// the NodeMap. In this case the value for each item
    132     /// is assigned by the value of the given ReadMap. 
     132    /// is assigned by the value of the given ReadMap.
    133133    template <typename CMap>
    134134    VectorMap& operator=(const CMap& cmap) {
     
    141141      return *this;
    142142    }
    143    
     143
    144144  public:
    145145
     
    147147    ///
    148148    /// The subscript operator. The map can be subscripted by the
    149     /// actual items of the graph.     
     149    /// actual items of the graph.
    150150    Reference operator[](const Key& key) {
    151151      return container[Parent::notifier()->id(key)];
    152     } 
    153                
     152    }
     153
    154154    /// \brief The const subcript operator.
    155155    ///
    156156    /// The const subscript operator. The map can be subscripted by the
    157     /// actual items of the graph. 
     157    /// actual items of the graph.
    158158    ConstReference operator[](const Key& key) const {
    159159      return container[Parent::notifier()->id(key)];
     
    171171
    172172    /// \brief Adds a new key to the map.
    173     ///         
     173    ///
    174174    /// It adds a new key to the map. It called by the observer notifier
    175     /// and it overrides the add() member function of the observer base.     
     175    /// and it overrides the add() member function of the observer base.
    176176    virtual void add(const Key& key) {
    177177      int id = Parent::notifier()->id(key);
    178178      if (id >= int(container.size())) {
    179         container.resize(id + 1);
     179        container.resize(id + 1);
    180180      }
    181181    }
    182182
    183183    /// \brief Adds more new keys to the map.
    184     ///         
     184    ///
    185185    /// It adds more new keys to the map. It called by the observer notifier
    186     /// and it overrides the add() member function of the observer base.     
     186    /// and it overrides the add() member function of the observer base.
    187187    virtual void add(const std::vector<Key>& keys) {
    188188      int max = container.size() - 1;
     
    199199    ///
    200200    /// Erase a key from the map. It called by the observer notifier
    201     /// and it overrides the erase() member function of the observer base.     
     201    /// and it overrides the erase() member function of the observer base.
    202202    virtual void erase(const Key& key) {
    203203      container[Parent::notifier()->id(key)] = Value();
     
    207207    ///
    208208    /// Erase more keys from the map. It called by the observer notifier
    209     /// and it overrides the erase() member function of the observer base.     
     209    /// and it overrides the erase() member function of the observer base.
    210210    virtual void erase(const std::vector<Key>& keys) {
    211211      for (int i = 0; i < int(keys.size()); ++i) {
    212         container[Parent::notifier()->id(keys[i])] = Value();
    213       }
    214     }
    215    
     212        container[Parent::notifier()->id(keys[i])] = Value();
     213      }
     214    }
     215
    216216    /// \brief Buildes the map.
    217     /// 
     217    ///
    218218    /// It buildes the map. It called by the observer notifier
    219219    /// and it overrides the build() member function of the observer base.
    220     virtual void build() { 
     220    virtual void build() {
    221221      int size = Parent::notifier()->maxId() + 1;
    222222      container.reserve(size);
     
    227227    ///
    228228    /// It erase all items from the map. It called by the observer notifier
    229     /// and it overrides the clear() member function of the observer base.     
    230     virtual void clear() { 
     229    /// and it overrides the clear() member function of the observer base.
     230    virtual void clear() {
    231231      container.clear();
    232232    }
    233    
     233
    234234  private:
    235                
     235
    236236    Container container;
    237237
Note: See TracChangeset for help on using the changeset viewer.