1.1 --- a/lemon/bits/vector_map.h Sun Jul 13 16:46:56 2008 +0100
1.2 +++ b/lemon/bits/vector_map.h Sun Jul 13 19:51:02 2008 +0100
1.3 @@ -1,6 +1,6 @@
1.4 -/* -*- C++ -*-
1.5 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
1.6 *
1.7 - * This file is a part of LEMON, a generic C++ optimization library
1.8 + * This file is a part of LEMON, a generic C++ optimization library.
1.9 *
1.10 * Copyright (C) 2003-2008
1.11 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
1.12 @@ -49,16 +49,16 @@
1.13 /// \tparam _Value The value type of the map.
1.14 /// \todo Fix the doc: there is _Graph parameter instead of _Notifier.
1.15 template <typename _Graph, typename _Item, typename _Value>
1.16 - class VectorMap
1.17 + class VectorMap
1.18 : public ItemSetTraits<_Graph, _Item>::ItemNotifier::ObserverBase {
1.19 private:
1.20 -
1.21 +
1.22 /// The container type of the map.
1.23 - typedef std::vector<_Value> Container;
1.24 + typedef std::vector<_Value> Container;
1.25
1.26 public:
1.27
1.28 - /// The graph type of the map.
1.29 + /// The graph type of the map.
1.30 typedef _Graph Graph;
1.31 /// The item type of the map.
1.32 typedef _Item Item;
1.33 @@ -93,9 +93,9 @@
1.34 container.resize(Parent::notifier()->maxId() + 1);
1.35 }
1.36
1.37 - /// \brief Constructor uses given value to initialize the map.
1.38 + /// \brief Constructor uses given value to initialize the map.
1.39 ///
1.40 - /// It constructs a map uses a given value to initialize the map.
1.41 + /// It constructs a map uses a given value to initialize the map.
1.42 /// It adds all the items of the graph to the map.
1.43 VectorMap(const Graph& graph, const Value& value) {
1.44 Parent::attach(graph.notifier(Item()));
1.45 @@ -107,18 +107,18 @@
1.46 /// Copy constructor.
1.47 VectorMap(const VectorMap& _copy) : Parent() {
1.48 if (_copy.attached()) {
1.49 - Parent::attach(*_copy.notifier());
1.50 - container = _copy.container;
1.51 + Parent::attach(*_copy.notifier());
1.52 + container = _copy.container;
1.53 }
1.54 }
1.55
1.56 /// \brief Assign operator.
1.57 ///
1.58 /// This operator assigns for each item in the map the
1.59 - /// value mapped to the same item in the copied map.
1.60 + /// value mapped to the same item in the copied map.
1.61 /// The parameter map should be indiced with the same
1.62 /// itemset because this assign operator does not change
1.63 - /// the container of the map.
1.64 + /// the container of the map.
1.65 VectorMap& operator=(const VectorMap& cmap) {
1.66 return operator=<VectorMap>(cmap);
1.67 }
1.68 @@ -129,7 +129,7 @@
1.69 /// The given parameter should be conform to the ReadMap
1.70 /// concecpt and could be indiced by the current item set of
1.71 /// the NodeMap. In this case the value for each item
1.72 - /// is assigned by the value of the given ReadMap.
1.73 + /// is assigned by the value of the given ReadMap.
1.74 template <typename CMap>
1.75 VectorMap& operator=(const CMap& cmap) {
1.76 checkConcept<concepts::ReadMap<Key, _Value>, CMap>();
1.77 @@ -140,21 +140,21 @@
1.78 }
1.79 return *this;
1.80 }
1.81 -
1.82 +
1.83 public:
1.84
1.85 /// \brief The subcript operator.
1.86 ///
1.87 /// The subscript operator. The map can be subscripted by the
1.88 - /// actual items of the graph.
1.89 + /// actual items of the graph.
1.90 Reference operator[](const Key& key) {
1.91 return container[Parent::notifier()->id(key)];
1.92 - }
1.93 -
1.94 + }
1.95 +
1.96 /// \brief The const subcript operator.
1.97 ///
1.98 /// The const subscript operator. The map can be subscripted by the
1.99 - /// actual items of the graph.
1.100 + /// actual items of the graph.
1.101 ConstReference operator[](const Key& key) const {
1.102 return container[Parent::notifier()->id(key)];
1.103 }
1.104 @@ -170,20 +170,20 @@
1.105 protected:
1.106
1.107 /// \brief Adds a new key to the map.
1.108 - ///
1.109 + ///
1.110 /// It adds a new key to the map. It called by the observer notifier
1.111 - /// and it overrides the add() member function of the observer base.
1.112 + /// and it overrides the add() member function of the observer base.
1.113 virtual void add(const Key& key) {
1.114 int id = Parent::notifier()->id(key);
1.115 if (id >= int(container.size())) {
1.116 - container.resize(id + 1);
1.117 + container.resize(id + 1);
1.118 }
1.119 }
1.120
1.121 /// \brief Adds more new keys to the map.
1.122 - ///
1.123 + ///
1.124 /// It adds more new keys to the map. It called by the observer notifier
1.125 - /// and it overrides the add() member function of the observer base.
1.126 + /// and it overrides the add() member function of the observer base.
1.127 virtual void add(const std::vector<Key>& keys) {
1.128 int max = container.size() - 1;
1.129 for (int i = 0; i < int(keys.size()); ++i) {
1.130 @@ -198,7 +198,7 @@
1.131 /// \brief Erase a key from the map.
1.132 ///
1.133 /// Erase a key from the map. It called by the observer notifier
1.134 - /// and it overrides the erase() member function of the observer base.
1.135 + /// and it overrides the erase() member function of the observer base.
1.136 virtual void erase(const Key& key) {
1.137 container[Parent::notifier()->id(key)] = Value();
1.138 }
1.139 @@ -206,18 +206,18 @@
1.140 /// \brief Erase more keys from the map.
1.141 ///
1.142 /// Erase more keys from the map. It called by the observer notifier
1.143 - /// and it overrides the erase() member function of the observer base.
1.144 + /// and it overrides the erase() member function of the observer base.
1.145 virtual void erase(const std::vector<Key>& keys) {
1.146 for (int i = 0; i < int(keys.size()); ++i) {
1.147 - container[Parent::notifier()->id(keys[i])] = Value();
1.148 + container[Parent::notifier()->id(keys[i])] = Value();
1.149 }
1.150 }
1.151 -
1.152 +
1.153 /// \brief Buildes the map.
1.154 - ///
1.155 + ///
1.156 /// It buildes the map. It called by the observer notifier
1.157 /// and it overrides the build() member function of the observer base.
1.158 - virtual void build() {
1.159 + virtual void build() {
1.160 int size = Parent::notifier()->maxId() + 1;
1.161 container.reserve(size);
1.162 container.resize(size);
1.163 @@ -226,13 +226,13 @@
1.164 /// \brief Clear the map.
1.165 ///
1.166 /// It erase all items from the map. It called by the observer notifier
1.167 - /// and it overrides the clear() member function of the observer base.
1.168 - virtual void clear() {
1.169 + /// and it overrides the clear() member function of the observer base.
1.170 + virtual void clear() {
1.171 container.clear();
1.172 }
1.173 -
1.174 +
1.175 private:
1.176 -
1.177 +
1.178 Container container;
1.179
1.180 };