1.1 --- a/lemon/bits/vector_map.h Tue Aug 30 21:19:07 2005 +0000
1.2 +++ b/lemon/bits/vector_map.h Wed Aug 31 13:29:32 2005 +0000
1.3 @@ -23,16 +23,20 @@
1.4 #include <lemon/utility.h>
1.5 #include <lemon/bits/map_iterator.h>
1.6 #include <lemon/bits/alteration_notifier.h>
1.7 +#include <lemon/concept_check.h>
1.8 +#include <lemon/concept/maps.h>
1.9
1.10 -///\ingroup graphmapfactory
1.11 +/// \ingroup graphmapfactory
1.12 +///
1.13 ///\file
1.14 ///\brief Vector based graph maps.
1.15
1.16 namespace lemon {
1.17 -
1.18 - /// \addtogroup graphmapfactory
1.19 - /// @{
1.20 -
1.21 +
1.22 + /// \ingroup graphmapfactory
1.23 + ///
1.24 + /// \brief Graph map based on the std::vector storage.
1.25 + ///
1.26 /// The VectorMap template class is graph map structure what
1.27 /// automatically updates the map when a key is added to or erased from
1.28 /// the map. This map factory uses the allocators to implement
1.29 @@ -117,39 +121,29 @@
1.30 }
1.31 }
1.32
1.33 - using Parent::attach;
1.34 - using Parent::detach;
1.35 - using Parent::attached;
1.36 -
1.37 - /** Assign operator to copy a map of the same map type.
1.38 - */
1.39 - VectorMap& operator=(const VectorMap& copy) {
1.40 - if (© == this) return *this;
1.41 -
1.42 - if (graph != copy.graph) {
1.43 - if (attached()) {
1.44 - detach();
1.45 - }
1.46 - if (copy.attached()) {
1.47 - attach(*copy.getRegistry());
1.48 - }
1.49 - }
1.50 - container = copy.container;
1.51 -
1.52 - return *this;
1.53 - }
1.54 -
1.55 -
1.56 virtual ~VectorMap() {
1.57 if (attached()) {
1.58 detach();
1.59 }
1.60 }
1.61
1.62 +
1.63 + private:
1.64 +
1.65 + VectorMap& operator=(const VectorMap&);
1.66 +
1.67 + protected:
1.68 +
1.69 + using Parent::attach;
1.70 + using Parent::detach;
1.71 + using Parent::attached;
1.72 +
1.73 const Graph* getGraph() const {
1.74 return graph;
1.75 }
1.76
1.77 + public:
1.78 +
1.79 /// The subcript operator.
1.80
1.81 /// The subscript operator. The map can be subscripted by the
1.82 @@ -173,13 +167,14 @@
1.83
1.84 /// It the same as operator[](key) = value expression.
1.85 ///
1.86 -
1.87 void set(const Key& key, const Value& value) {
1.88 (*this)[key] = value;
1.89 }
1.90
1.91 - /// Adds a new key to the map.
1.92 -
1.93 + protected:
1.94 +
1.95 + /// \brief Adds a new key to the map.
1.96 + ///
1.97 /// It adds a new key to the map. It called by the observer registry
1.98 /// and it overrides the add() member function of the observer base.
1.99
1.100 @@ -220,69 +215,6 @@
1.101
1.102 };
1.103
1.104 -
1.105 - template <typename _Base>
1.106 - class VectorMappableGraphExtender : public _Base {
1.107 - public:
1.108 -
1.109 - typedef VectorMappableGraphExtender<_Base> Graph;
1.110 - typedef _Base Parent;
1.111 -
1.112 - typedef typename Parent::Node Node;
1.113 - typedef typename Parent::NodeIt NodeIt;
1.114 - typedef typename Parent::NodeIdMap NodeIdMap;
1.115 - typedef typename Parent::NodeNotifier NodeObserverRegistry;
1.116 -
1.117 - typedef typename Parent::Edge Edge;
1.118 - typedef typename Parent::EdgeIt EdgeIt;
1.119 - typedef typename Parent::EdgeIdMap EdgeIdMap;
1.120 - typedef typename Parent::EdgeNotifier EdgeObserverRegistry;
1.121 -
1.122 -
1.123 - template <typename _Value>
1.124 - class NodeMap :
1.125 - public IterableMapExtender<VectorMap<Graph, Node, _Value> > {
1.126 - public:
1.127 - typedef VectorMappableGraphExtender<_Base> Graph;
1.128 -
1.129 - typedef typename Graph::Node Node;
1.130 -
1.131 - typedef IterableMapExtender<VectorMap<Graph, Node, _Value> > Parent;
1.132 -
1.133 - //typedef typename Parent::Graph Graph;
1.134 - typedef typename Parent::Value Value;
1.135 -
1.136 - NodeMap(const Graph& g)
1.137 - : Parent(g) {}
1.138 - NodeMap(const Graph& g, const Value& v)
1.139 - : Parent(g, v) {}
1.140 -
1.141 - };
1.142 -
1.143 - template <typename _Value>
1.144 - class EdgeMap
1.145 - : public IterableMapExtender<VectorMap<Graph, Edge, _Value> > {
1.146 - public:
1.147 - typedef VectorMappableGraphExtender<_Base> Graph;
1.148 -
1.149 - typedef typename Graph::Edge Edge;
1.150 -
1.151 - typedef IterableMapExtender<VectorMap<Graph, Edge, _Value> > Parent;
1.152 -
1.153 - //typedef typename Parent::Graph Graph;
1.154 - typedef typename Parent::Value Value;
1.155 -
1.156 - EdgeMap(const Graph& g)
1.157 - : Parent(g) {}
1.158 - EdgeMap(const Graph& g, const Value& v)
1.159 - : Parent(g, v) {}
1.160 -
1.161 - };
1.162 -
1.163 - };
1.164 -
1.165 - /// @}
1.166 -
1.167 }
1.168
1.169 #endif