1.1 --- a/lemon/bits/static_map.h Wed Feb 22 12:45:59 2006 +0000
1.2 +++ b/lemon/bits/static_map.h Wed Feb 22 18:26:56 2006 +0000
1.3 @@ -56,11 +56,11 @@
1.4 class StaticMap : public AlterationNotifier<_Item>::ObserverBase {
1.5 public:
1.6
1.7 - /// \brief Exception class for unsinported exceptions.
1.8 - class UnsinportedOperation : public lemon::LogicError {
1.9 + /// \brief Exception class for unsupported exceptions.
1.10 + class UnsupportedOperation : public lemon::LogicError {
1.11 public:
1.12 virtual const char* exceptionName() const {
1.13 - return "lemon::StaticMap::UnsinportedOperation";
1.14 + return "lemon::StaticMap::UnsupportedOperation";
1.15 }
1.16 };
1.17
1.18 @@ -187,7 +187,7 @@
1.19 /// and it overrides the add() member function of the observer base.
1.20
1.21 void add(const Key&) {
1.22 - throw UnsinportedOperation();
1.23 + throw UnsupportedOperation();
1.24 }
1.25
1.26 /// \brief Erases a key from the map.
1.27 @@ -195,7 +195,7 @@
1.28 /// Erase a key from the map. It called by the observer registry
1.29 /// and it overrides the erase() member function of the observer base.
1.30 void erase(const Key&) {
1.31 - throw UnsinportedOperation();
1.32 + throw UnsupportedOperation();
1.33 }
1.34
1.35 /// Buildes the map.
1.36 @@ -224,396 +224,6 @@
1.37
1.38 };
1.39
1.40 - /// \e
1.41 - template <typename _Base>
1.42 - class StaticMappableGraphExtender : public _Base {
1.43 - public:
1.44 -
1.45 - typedef StaticMappableGraphExtender<_Base> Graph;
1.46 - typedef _Base Parent;
1.47 -
1.48 - typedef typename Parent::Node Node;
1.49 - typedef typename Parent::NodeIt NodeIt;
1.50 -
1.51 - typedef typename Parent::Edge Edge;
1.52 - typedef typename Parent::EdgeIt EdgeIt;
1.53 -
1.54 -
1.55 - template <typename _Value>
1.56 - class NodeMap
1.57 - : public IterableMapExtender<StaticMap<Graph, Node, _Value> > {
1.58 - public:
1.59 - typedef StaticMappableGraphExtender Graph;
1.60 - typedef IterableMapExtender<StaticMap<Graph, Node, _Value> > Parent;
1.61 -
1.62 - NodeMap(const Graph& _g)
1.63 - : Parent(_g) {}
1.64 - NodeMap(const Graph& _g, const _Value& _v)
1.65 - : Parent(_g, _v) {}
1.66 -
1.67 - NodeMap& operator=(const NodeMap& cmap) {
1.68 - return operator=<NodeMap>(cmap);
1.69 - }
1.70 -
1.71 -
1.72 - /// \brief Template assign operator.
1.73 - ///
1.74 - /// The given parameter should be conform to the ReadMap
1.75 - /// concecpt and could be indiced by the current item set of
1.76 - /// the NodeMap. In this case the value for each item
1.77 - /// is assigned by the value of the given ReadMap.
1.78 - template <typename CMap>
1.79 - NodeMap& operator=(const CMap& cmap) {
1.80 - checkConcept<concept::ReadMap<Node, _Value>, CMap>();
1.81 - const typename Parent::Graph* graph = Parent::getGraph();
1.82 - Node it;
1.83 - for (graph->first(it); it != INVALID; graph->next(it)) {
1.84 - Parent::set(it, cmap[it]);
1.85 - }
1.86 - return *this;
1.87 - }
1.88 -
1.89 - };
1.90 -
1.91 - template <typename _Value>
1.92 - class EdgeMap
1.93 - : public IterableMapExtender<StaticMap<Graph, Edge, _Value> > {
1.94 - public:
1.95 - typedef StaticMappableGraphExtender Graph;
1.96 - typedef IterableMapExtender<StaticMap<Graph, Edge, _Value> > Parent;
1.97 -
1.98 - EdgeMap(const Graph& _g)
1.99 - : Parent(_g) {}
1.100 - EdgeMap(const Graph& _g, const _Value& _v)
1.101 - : Parent(_g, _v) {}
1.102 -
1.103 - EdgeMap& operator=(const EdgeMap& cmap) {
1.104 - return operator=<EdgeMap>(cmap);
1.105 - }
1.106 -
1.107 - template <typename CMap>
1.108 - EdgeMap& operator=(const CMap& cmap) {
1.109 - checkConcept<concept::ReadMap<Edge, _Value>, CMap>();
1.110 - const typename Parent::Graph* graph = Parent::getGraph();
1.111 - Edge it;
1.112 - for (graph->first(it); it != INVALID; graph->next(it)) {
1.113 - Parent::set(it, cmap[it]);
1.114 - }
1.115 - return *this;
1.116 - }
1.117 - };
1.118 -
1.119 - };
1.120 -
1.121 - /// \e
1.122 - template <typename _Base>
1.123 - class StaticMappableUGraphExtender :
1.124 - public StaticMappableGraphExtender<_Base> {
1.125 - public:
1.126 -
1.127 - typedef StaticMappableUGraphExtender Graph;
1.128 - typedef StaticMappableGraphExtender<_Base> Parent;
1.129 -
1.130 - typedef typename Parent::UEdge UEdge;
1.131 -
1.132 - template <typename _Value>
1.133 - class UEdgeMap
1.134 - : public IterableMapExtender<StaticMap<Graph, UEdge, _Value> > {
1.135 - public:
1.136 - typedef StaticMappableUGraphExtender Graph;
1.137 - typedef IterableMapExtender<
1.138 - StaticMap<Graph, UEdge, _Value> > Parent;
1.139 -
1.140 - UEdgeMap(const Graph& _g)
1.141 - : Parent(_g) {}
1.142 - UEdgeMap(const Graph& _g, const _Value& _v)
1.143 - : Parent(_g, _v) {}
1.144 -
1.145 - UEdgeMap& operator=(const UEdgeMap& cmap) {
1.146 - return operator=<UEdgeMap>(cmap);
1.147 - }
1.148 -
1.149 - template <typename CMap>
1.150 - UEdgeMap& operator=(const CMap& cmap) {
1.151 - checkConcept<concept::ReadMap<UEdge, _Value>, CMap>();
1.152 - const typename Parent::Graph* graph = Parent::getGraph();
1.153 - UEdge it;
1.154 - for (graph->first(it); it != INVALID; graph->next(it)) {
1.155 - Parent::set(it, cmap[it]);
1.156 - }
1.157 - return *this;
1.158 - }
1.159 - };
1.160 -
1.161 - };
1.162 -
1.163 - template <typename _Base>
1.164 - class StaticMappableBpUGraphExtender : public _Base {
1.165 - public:
1.166 -
1.167 - typedef _Base Parent;
1.168 - typedef StaticMappableBpUGraphExtender Graph;
1.169 -
1.170 - typedef typename Parent::Node Node;
1.171 - typedef typename Parent::ANode ANode;
1.172 - typedef typename Parent::BNode BNode;
1.173 - typedef typename Parent::Edge Edge;
1.174 - typedef typename Parent::UEdge UEdge;
1.175 -
1.176 - template <typename _Value>
1.177 - class ANodeMap
1.178 - : public IterableMapExtender<StaticMap<Graph, ANode, _Value> > {
1.179 - public:
1.180 - typedef StaticMappableBpUGraphExtender Graph;
1.181 - typedef IterableMapExtender<StaticMap<Graph, ANode, _Value> >
1.182 - Parent;
1.183 -
1.184 - ANodeMap(const Graph& _g)
1.185 - : Parent(_g) {}
1.186 - ANodeMap(const Graph& _g, const _Value& _v)
1.187 - : Parent(_g, _v) {}
1.188 -
1.189 - ANodeMap& operator=(const ANodeMap& cmap) {
1.190 - return operator=<ANodeMap>(cmap);
1.191 - }
1.192 -
1.193 -
1.194 - /// \brief Template assign operator.
1.195 - ///
1.196 - /// The given parameter should be conform to the ReadMap
1.197 - /// concept and could be indiced by the current item set of
1.198 - /// the ANodeMap. In this case the value for each item
1.199 - /// is assigned by the value of the given ReadMap.
1.200 - template <typename CMap>
1.201 - ANodeMap& operator=(const CMap& cmap) {
1.202 - checkConcept<concept::ReadMap<ANode, _Value>, CMap>();
1.203 - const typename Parent::Graph* graph = Parent::getGraph();
1.204 - ANode it;
1.205 - for (graph->first(it); it != INVALID; graph->next(it)) {
1.206 - Parent::set(it, cmap[it]);
1.207 - }
1.208 - return *this;
1.209 - }
1.210 -
1.211 - };
1.212 -
1.213 - template <typename _Value>
1.214 - class BNodeMap
1.215 - : public IterableMapExtender<StaticMap<Graph, BNode, _Value> > {
1.216 - public:
1.217 - typedef StaticMappableBpUGraphExtender Graph;
1.218 - typedef IterableMapExtender<StaticMap<Graph, BNode, _Value> >
1.219 - Parent;
1.220 -
1.221 - BNodeMap(const Graph& _g)
1.222 - : Parent(_g) {}
1.223 - BNodeMap(const Graph& _g, const _Value& _v)
1.224 - : Parent(_g, _v) {}
1.225 -
1.226 - BNodeMap& operator=(const BNodeMap& cmap) {
1.227 - return operator=<BNodeMap>(cmap);
1.228 - }
1.229 -
1.230 -
1.231 - /// \brief Template assign operator.
1.232 - ///
1.233 - /// The given parameter should be conform to the ReadMap
1.234 - /// concept and could be indiced by the current item set of
1.235 - /// the BNodeMap. In this case the value for each item
1.236 - /// is assigned by the value of the given ReadMap.
1.237 - template <typename CMap>
1.238 - BNodeMap& operator=(const CMap& cmap) {
1.239 - checkConcept<concept::ReadMap<BNode, _Value>, CMap>();
1.240 - const typename Parent::Graph* graph = Parent::getGraph();
1.241 - BNode it;
1.242 - for (graph->first(it); it != INVALID; graph->next(it)) {
1.243 - Parent::set(it, cmap[it]);
1.244 - }
1.245 - return *this;
1.246 - }
1.247 -
1.248 - };
1.249 -
1.250 - protected:
1.251 -
1.252 - template <typename _Value>
1.253 - class NodeMapBase : public Parent::NodeNotifier::ObserverBase {
1.254 - public:
1.255 - typedef StaticMappableBpUGraphExtender Graph;
1.256 -
1.257 - typedef Node Key;
1.258 - typedef _Value Value;
1.259 -
1.260 - /// The reference type of the map;
1.261 - typedef typename BNodeMap<_Value>::Reference Reference;
1.262 - /// The pointer type of the map;
1.263 - typedef typename BNodeMap<_Value>::Pointer Pointer;
1.264 -
1.265 - /// The const value type of the map.
1.266 - typedef const Value ConstValue;
1.267 - /// The const reference type of the map;
1.268 - typedef typename BNodeMap<_Value>::ConstReference ConstReference;
1.269 - /// The pointer type of the map;
1.270 - typedef typename BNodeMap<_Value>::ConstPointer ConstPointer;
1.271 -
1.272 - typedef True ReferenceMapTag;
1.273 -
1.274 - NodeMapBase(const Graph& _g)
1.275 - : graph(&_g), bNodeMap(_g), aNodeMap(_g) {
1.276 - Parent::NodeNotifier::ObserverBase::attach(_g.getNotifier(Node()));
1.277 - }
1.278 - NodeMapBase(const Graph& _g, const _Value& _v)
1.279 - : graph(&_g), bNodeMap(_g, _v),
1.280 - aNodeMap(_g, _v) {
1.281 - Parent::NodeNotifier::ObserverBase::attach(_g.getNotifier(Node()));
1.282 - }
1.283 -
1.284 - virtual ~NodeMapBase() {
1.285 - if (Parent::NodeNotifier::ObserverBase::attached()) {
1.286 - Parent::NodeNotifier::ObserverBase::detach();
1.287 - }
1.288 - }
1.289 -
1.290 - ConstReference operator[](const Key& node) const {
1.291 - if (Parent::aNode(node)) {
1.292 - return aNodeMap[node];
1.293 - } else {
1.294 - return bNodeMap[node];
1.295 - }
1.296 - }
1.297 -
1.298 - Reference operator[](const Key& node) {
1.299 - if (Parent::aNode(node)) {
1.300 - return aNodeMap[node];
1.301 - } else {
1.302 - return bNodeMap[node];
1.303 - }
1.304 - }
1.305 -
1.306 - void set(const Key& node, const Value& value) {
1.307 - if (Parent::aNode(node)) {
1.308 - aNodeMap.set(node, value);
1.309 - } else {
1.310 - bNodeMap.set(node, value);
1.311 - }
1.312 - }
1.313 -
1.314 - protected:
1.315 -
1.316 - virtual void add(const Node&) {}
1.317 - virtual void add(const std::vector<Node>&) {}
1.318 - virtual void erase(const Node&) {}
1.319 - virtual void erase(const std::vector<Node>&) {}
1.320 - virtual void clear() {}
1.321 - virtual void build() {}
1.322 -
1.323 - const Graph* getGraph() const { return graph; }
1.324 -
1.325 - private:
1.326 - const Graph* graph;
1.327 - BNodeMap<_Value> bNodeMap;
1.328 - ANodeMap<_Value> aNodeMap;
1.329 - };
1.330 -
1.331 - public:
1.332 -
1.333 - template <typename _Value>
1.334 - class NodeMap
1.335 - : public IterableMapExtender<NodeMapBase<_Value> > {
1.336 - public:
1.337 - typedef StaticMappableBpUGraphExtender Graph;
1.338 - typedef IterableMapExtender< NodeMapBase<_Value> > Parent;
1.339 -
1.340 - NodeMap(const Graph& _g)
1.341 - : Parent(_g) {}
1.342 - NodeMap(const Graph& _g, const _Value& _v)
1.343 - : Parent(_g, _v) {}
1.344 -
1.345 - NodeMap& operator=(const NodeMap& cmap) {
1.346 - return operator=<NodeMap>(cmap);
1.347 - }
1.348 -
1.349 -
1.350 - /// \brief Template assign operator.
1.351 - ///
1.352 - /// The given parameter should be conform to the ReadMap
1.353 - /// concept and could be indiced by the current item set of
1.354 - /// the NodeMap. In this case the value for each item
1.355 - /// is assigned by the value of the given ReadMap.
1.356 - template <typename CMap>
1.357 - NodeMap& operator=(const CMap& cmap) {
1.358 - checkConcept<concept::ReadMap<Node, _Value>, CMap>();
1.359 - const typename Parent::Graph* graph = Parent::getGraph();
1.360 - Node it;
1.361 - for (graph->first(it); it != INVALID; graph->next(it)) {
1.362 - Parent::set(it, cmap[it]);
1.363 - }
1.364 - return *this;
1.365 - }
1.366 -
1.367 - };
1.368 -
1.369 -
1.370 -
1.371 - template <typename _Value>
1.372 - class EdgeMap
1.373 - : public IterableMapExtender<StaticMap<Graph, Edge, _Value> > {
1.374 - public:
1.375 - typedef StaticMappableBpUGraphExtender Graph;
1.376 - typedef IterableMapExtender<StaticMap<Graph, Edge, _Value> > Parent;
1.377 -
1.378 - EdgeMap(const Graph& _g)
1.379 - : Parent(_g) {}
1.380 - EdgeMap(const Graph& _g, const _Value& _v)
1.381 - : Parent(_g, _v) {}
1.382 -
1.383 - EdgeMap& operator=(const EdgeMap& cmap) {
1.384 - return operator=<EdgeMap>(cmap);
1.385 - }
1.386 -
1.387 - template <typename CMap>
1.388 - EdgeMap& operator=(const CMap& cmap) {
1.389 - checkConcept<concept::ReadMap<Edge, _Value>, CMap>();
1.390 - const typename Parent::Graph* graph = Parent::getGraph();
1.391 - Edge it;
1.392 - for (graph->first(it); it != INVALID; graph->next(it)) {
1.393 - Parent::set(it, cmap[it]);
1.394 - }
1.395 - return *this;
1.396 - }
1.397 - };
1.398 -
1.399 - template <typename _Value>
1.400 - class UEdgeMap
1.401 - : public IterableMapExtender<StaticMap<Graph, UEdge, _Value> > {
1.402 - public:
1.403 - typedef StaticMappableBpUGraphExtender Graph;
1.404 - typedef IterableMapExtender<StaticMap<Graph, UEdge, _Value> >
1.405 - Parent;
1.406 -
1.407 - UEdgeMap(const Graph& _g)
1.408 - : Parent(_g) {}
1.409 - UEdgeMap(const Graph& _g, const _Value& _v)
1.410 - : Parent(_g, _v) {}
1.411 -
1.412 - UEdgeMap& operator=(const UEdgeMap& cmap) {
1.413 - return operator=<UEdgeMap>(cmap);
1.414 - }
1.415 -
1.416 - template <typename CMap>
1.417 - UEdgeMap& operator=(const CMap& cmap) {
1.418 - checkConcept<concept::ReadMap<UEdge, _Value>, CMap>();
1.419 - const typename Parent::Graph* graph = Parent::getGraph();
1.420 - UEdge it;
1.421 - for (graph->first(it); it != INVALID; graph->next(it)) {
1.422 - Parent::set(it, cmap[it]);
1.423 - }
1.424 - return *this;
1.425 - }
1.426 - };
1.427 -
1.428 - };
1.429 -
1.430 }
1.431
1.432 #endif