# HG changeset patch # User deba # Date 1100165515 0 # Node ID 0f1044b7a3af531b57dd59c6fb82a42bb8698b49 # Parent b5fb023cdb7b9c94ff112a9d6e0676002339ee9a maxNodeId() and maxEdgeId() changed to maxId(Node) and maxId(Edge) getNodeObserverRegistry() and getEdgeObserverRegistry() changed to getObserverRegistry(Node) and getObserverRegistry(Edge) IdMappableGraphExtender erased diff -r b5fb023cdb7b -r 0f1044b7a3af src/lemon/Makefile.am --- a/src/lemon/Makefile.am Wed Nov 10 21:59:59 2004 +0000 +++ b/src/lemon/Makefile.am Thu Nov 11 09:31:55 2004 +0000 @@ -1,4 +1,5 @@ pkginclude_HEADERS = \ + map_defines.h \ array_map.h \ bfs.h \ dfs.h \ @@ -6,7 +7,6 @@ default_map.h \ dijkstra.h \ dimacs.h \ - extended_pair.h \ fib_heap.h \ full_graph.h \ graph_wrapper.h \ @@ -14,7 +14,6 @@ invalid.h \ kruskal.h \ list_graph.h \ - map_iterator.h \ alteration_observer_registry.h \ maps.h \ min_cost_flow.h \ @@ -27,11 +26,8 @@ vector_map.h \ xy.h \ concept_check.h \ - map_defines.h \ - map_bits.h \ utility.h \ iterable_graph_extender.h \ - idmappable_graph_extender.h \ extendable_graph_extender.h \ clearable_graph_extender.h \ erasable_graph_extender.h \ diff -r b5fb023cdb7b -r 0f1044b7a3af src/lemon/alteration_observer_registry.h --- a/src/lemon/alteration_observer_registry.h Wed Nov 10 21:59:59 2004 +0000 +++ b/src/lemon/alteration_observer_registry.h Thu Nov 11 09:31:55 2004 +0000 @@ -321,11 +321,11 @@ public: - EdgeObserverRegistry& getEdgeObserverRegistry() const { + EdgeObserverRegistry& getObserverRegistry(Edge = INVALID) const { return edge_observers; } - NodeObserverRegistry& getNodeObserverRegistry() const { + NodeObserverRegistry& getObserverRegistry(Node = INVALID) const { return node_observers; } @@ -364,7 +364,7 @@ mutable UndirEdgeObserverRegistry undir_edge_observers; - UndirEdgeObserverRegistry& getUndirEdgeObserverRegistry() const { + UndirEdgeObserverRegistry& getObserverRegistry(UndirEdge = INVALID) const { return undir_edge_observers; } diff -r b5fb023cdb7b -r 0f1044b7a3af src/lemon/array_map.h --- a/src/lemon/array_map.h Wed Nov 10 21:59:59 2004 +0000 +++ b/src/lemon/array_map.h Thu Nov 11 09:31:55 2004 +0000 @@ -44,7 +44,6 @@ template class ArrayMap : public AlterationObserverRegistry<_Item>::ObserverBase { @@ -61,8 +60,6 @@ /// The iterator to iterate on the keys. typedef _ItemIt KeyIt; - typedef _IdMap IdMap; - typedef _Value Value; /// The MapBase of the Map which imlements the core regisitry function. @@ -94,11 +91,11 @@ /** Graph and Registry initialized map constructor. */ - ArrayMap(const Graph& _g, Registry& _r) : graph(&_g) { - attach(_r); + ArrayMap(const Graph& _g) : graph(&_g) { + attach(_g.getObserverRegistry(_Item())); allocate_memory(); for (KeyIt it(*graph); it != INVALID; ++it) { - int id = IdMap(*graph)[it]; + int id = graph->id(it);; allocator.construct(&(values[id]), Value()); } } @@ -107,11 +104,11 @@ /// It constrates a map and initialize all of the the map. - ArrayMap(const Graph& _g, Registry& _r, const Value& _v) : graph(&_g) { - attach(_r); + ArrayMap(const Graph& _g, const Value& _v) : graph(&_g) { + attach(_g.getObserverRegistry(_Item())); allocate_memory(); for (KeyIt it(*graph); it != INVALID; ++it) { - int id = IdMap(*graph)[it]; + int id = graph->id(it);; allocator.construct(&(values[id]), _v); } } @@ -126,7 +123,7 @@ if (capacity == 0) return; values = allocator.allocate(capacity); for (KeyIt it(*graph); it != INVALID; ++it) { - int id = IdMap(*graph)[it]; + int id = graph->id(it);; allocator.construct(&(values[id]), copy.values[id]); } } @@ -154,7 +151,7 @@ } for (KeyIt it(*graph); it != INVALID; ++it) { - int id = IdMap(*graph)[it]; + int id = graph->id(it);; allocator.construct(&(values[id]), copy.values[id]); } @@ -176,7 +173,7 @@ * actual keys of the graph. */ ReferenceType operator[](const KeyType& key) { - int id = IdMap(*graph)[key]; + int id = graph->id(key); return values[id]; } @@ -185,7 +182,7 @@ * actual keys of the graph. */ ConstReferenceType operator[](const KeyType& key) const { - int id = IdMap(*graph)[key]; + int id = graph->id(key); return values[id]; } @@ -199,7 +196,7 @@ /** Add a new key to the map. It called by the map registry. */ void add(const KeyType& key) { - int id = IdMap(*graph)[key]; + int id = graph->id(key); if (id >= capacity) { int new_capacity = (capacity == 0 ? 1 : capacity); while (new_capacity <= id) { @@ -207,7 +204,7 @@ } Value* new_values = allocator.allocate(new_capacity); for (KeyIt it(*graph); it != INVALID; ++it) { - int jd = IdMap(*graph)[it]; + int jd = graph->id(it);; if (id != jd) { allocator.construct(&(new_values[jd]), values[jd]); allocator.destroy(&(values[jd])); @@ -223,14 +220,14 @@ /** Erase a key from the map. It called by the map registry. */ void erase(const KeyType& key) { - int id = IdMap(*graph)[key]; + int id = graph->id(key); allocator.destroy(&(values[id])); } void build() { allocate_memory(); for (KeyIt it(*graph); it != INVALID; ++it) { - int id = IdMap(*graph)[it]; + int id = graph->id(it);; allocator.construct(&(values[id]), Value()); } } @@ -238,7 +235,7 @@ void clear() { if (capacity != 0) { for (KeyIt it(*graph); it != INVALID; ++it) { - int id = IdMap(*graph)[it]; + int id = graph->id(it);; allocator.destroy(&(values[id])); } allocator.deallocate(values, capacity); @@ -302,7 +299,7 @@ private: void allocate_memory() { - int max_id = IdMap(*graph).maxId(); + int max_id = graph->maxId(_Item()); if (max_id == -1) { capacity = 0; values = 0; @@ -343,55 +340,51 @@ typedef typename Parent::Node Node; typedef typename Parent::NodeIt NodeIt; - typedef typename Parent::NodeIdMap NodeIdMap; typedef typename Parent::NodeObserverRegistry NodeObserverRegistry; typedef typename Parent::Edge Edge; typedef typename Parent::EdgeIt EdgeIt; - typedef typename Parent::EdgeIdMap EdgeIdMap; typedef typename Parent::EdgeObserverRegistry EdgeObserverRegistry; template - class NodeMap : public ArrayMap { + class NodeMap : public ArrayMap { public: typedef ArrayMappableGraphExtender<_Base> Graph; typedef typename Graph::Node Node; typedef typename Graph::NodeIt NodeIt; - typedef typename Graph::NodeIdMap NodeIdMap; - typedef ArrayMap Parent; + typedef ArrayMap Parent; //typedef typename Parent::Graph Graph; typedef typename Parent::Value Value; NodeMap(const Graph& g) - : Parent(g, g.getNodeObserverRegistry()) {} + : Parent(g) {} NodeMap(const Graph& g, const Value& v) - : Parent(g, g.getNodeObserverRegistry(), v) {} + : Parent(g, v) {} }; template - class EdgeMap : public ArrayMap { + class EdgeMap : public ArrayMap { public: typedef ArrayMappableGraphExtender<_Base> Graph; typedef typename Graph::Edge Edge; typedef typename Graph::EdgeIt EdgeIt; - typedef typename Graph::EdgeIdMap EdgeIdMap; - typedef ArrayMap Parent; + typedef ArrayMap Parent; //typedef typename Parent::Graph Graph; typedef typename Parent::Value Value; EdgeMap(const Graph& g) - : Parent(g, g.getEdgeObserverRegistry()) {} + : Parent(g) {} EdgeMap(const Graph& g, const Value& v) - : Parent(g, g.getEdgeObserverRegistry(), v) {} + : Parent(g, v) {} }; diff -r b5fb023cdb7b -r 0f1044b7a3af src/lemon/clearable_graph_extender.h --- a/src/lemon/clearable_graph_extender.h Wed Nov 10 21:59:59 2004 +0000 +++ b/src/lemon/clearable_graph_extender.h Thu Nov 11 09:31:55 2004 +0000 @@ -14,10 +14,12 @@ typedef ClearableGraphExtender Graph; typedef _Base Parent; + typedef typename Parent::Node Node; + typedef typename Parent::Edge Edge; void clear() { - Parent::getNodeObserverRegistry().clear(); - Parent::getEdgeObserverRegistry().clear(); + Parent::getObserverRegistry(Node()).clear(); + Parent::getObserverRegistry(Edge()).clear(); Parent::clear(); } diff -r b5fb023cdb7b -r 0f1044b7a3af src/lemon/concept/graph_component.h --- a/src/lemon/concept/graph_component.h Wed Nov 10 21:59:59 2004 +0000 +++ b/src/lemon/concept/graph_component.h Thu Nov 11 09:31:55 2004 +0000 @@ -161,6 +161,10 @@ Node(Invalid) {} + /// Assign operator for nodes. + + /// The nodes are assignable. + /// Node& operator=(const Node&) { return *this;} /// Equality operator. @@ -210,7 +214,10 @@ /// \sa Invalid for more details. Edge(Invalid) {} + /// Assign operator for edges. + /// The edges are assignable. + /// Edge& operator=(const Edge&) { return *this;} /// Equality operator. @@ -429,13 +436,13 @@ /// Gives back an integer greater or equal to the maximum Node id. /// - int maxEdgeId() const { return -1;} + int maxId(Node = INVALID) const { return -1;} /// Gives back an integer greater or equal to the maximum Edge id. /// Gives back an integer greater or equal to the maximum Edge id. /// - int maxNodeId() const { return -1;} + int maxId(Edge = INVALID) const { return -1;} }; /// Concept check structure for MaxIdableBaseGraph. @@ -447,9 +454,9 @@ void constraints() { function_requires< BaseGraphComponentConcept >(); - int nid = graph.maxEdgeId(); + int nid = graph.maxId(typename Graph::Node()); ignore_unused_variable_warning(nid); - int eid = graph.maxNodeId(); + int eid = graph.maxId(typename Graph::Edge()); ignore_unused_variable_warning(eid); } @@ -662,52 +669,6 @@ }; - class IdMappableGraphComponent : virtual public BaseGraphComponent { - - typedef IdMappableGraphComponent Graph; - - public: - - typedef BaseGraphComponent::Node Node; - typedef BaseGraphComponent::Edge Edge; - - class NodeIdMap : public ReadMap { - public: - NodeIdMap(const Graph&) {} - int maxId() const { return -1;} - }; - - class EdgeIdMap : public ReadMap { - public: - EdgeIdMap(const Graph&) {} - int maxId() const { return -1;} - }; - - }; - - template - struct IdMappableGraphComponentConcept { - void constraints() { - function_requires< BaseGraphComponentConcept >(); - { - typedef typename Graph::EdgeIdMap EdgeIdMap; - function_requires >(); - EdgeIdMap edge_map(graph); - int n = edge_map.maxId(); - ignore_unused_variable_warning(n); - } - { - typedef typename Graph::NodeIdMap NodeIdMap; - function_requires >(); - NodeIdMap node_map(graph); - int n = node_map.maxId(); - ignore_unused_variable_warning(n); - } - } - Graph& graph; - }; - - class MappableGraphComponent : virtual public BaseGraphComponent { public: diff -r b5fb023cdb7b -r 0f1044b7a3af src/lemon/default_map.h --- a/src/lemon/default_map.h Wed Nov 10 21:59:59 2004 +0000 +++ b/src/lemon/default_map.h Thu Nov 11 09:31:55 2004 +0000 @@ -42,97 +42,97 @@ - template + template struct DefaultMapSelector { - typedef ArrayMap<_Graph, _Item, _ItemIt, _IdMap, _Value> Map; + typedef ArrayMap<_Graph, _Item, _ItemIt, _Value> Map; }; // bool - template - struct DefaultMapSelector<_Graph, _Item, _ItemIt, _IdMap, bool> { - typedef VectorMap<_Graph, _Item, _IdMap, bool> Map; + template + struct DefaultMapSelector<_Graph, _Item, _ItemIt, bool> { + typedef VectorMap<_Graph, _Item, bool> Map; }; // char - template - struct DefaultMapSelector<_Graph, _Item, _ItemIt, _IdMap, char> { - typedef VectorMap<_Graph, _Item, _IdMap, char> Map; + template + struct DefaultMapSelector<_Graph, _Item, _ItemIt, char> { + typedef VectorMap<_Graph, _Item, char> Map; }; - template - struct DefaultMapSelector<_Graph, _Item, _ItemIt, _IdMap, signed char> { - typedef VectorMap<_Graph, _Item, _IdMap, signed char> Map; + template + struct DefaultMapSelector<_Graph, _Item, _ItemIt, signed char> { + typedef VectorMap<_Graph, _Item, signed char> Map; }; - template - struct DefaultMapSelector<_Graph, _Item, _ItemIt, _IdMap, unsigned char> { - typedef VectorMap<_Graph, _Item, _IdMap, unsigned char> Map; + template + struct DefaultMapSelector<_Graph, _Item, _ItemIt, unsigned char> { + typedef VectorMap<_Graph, _Item, unsigned char> Map; }; // int - template - struct DefaultMapSelector<_Graph, _Item, _ItemIt, _IdMap, signed int> { - typedef VectorMap<_Graph, _Item, _IdMap, signed int> Map; + template + struct DefaultMapSelector<_Graph, _Item, _ItemIt, signed int> { + typedef VectorMap<_Graph, _Item, signed int> Map; }; - template - struct DefaultMapSelector<_Graph, _Item, _ItemIt, _IdMap, unsigned int> { - typedef VectorMap<_Graph, _Item, _IdMap, unsigned int> Map; + template + struct DefaultMapSelector<_Graph, _Item, _ItemIt, unsigned int> { + typedef VectorMap<_Graph, _Item, unsigned int> Map; }; // short - template - struct DefaultMapSelector<_Graph, _Item, _ItemIt, _IdMap, signed short> { - typedef VectorMap<_Graph, _Item, _IdMap, signed short> Map; + template + struct DefaultMapSelector<_Graph, _Item, _ItemIt, signed short> { + typedef VectorMap<_Graph, _Item, signed short> Map; }; - template - struct DefaultMapSelector<_Graph, _Item, _ItemIt, _IdMap, unsigned short> { - typedef VectorMap<_Graph, _Item, _IdMap, unsigned short> Map; + template + struct DefaultMapSelector<_Graph, _Item, _ItemIt, unsigned short> { + typedef VectorMap<_Graph, _Item, unsigned short> Map; }; // long - template - struct DefaultMapSelector<_Graph, _Item, _ItemIt, _IdMap, signed long> { - typedef VectorMap<_Graph, _Item, _IdMap, signed long> Map; + template + struct DefaultMapSelector<_Graph, _Item, _ItemIt, signed long> { + typedef VectorMap<_Graph, _Item, signed long> Map; }; - template - struct DefaultMapSelector<_Graph, _Item, _ItemIt, _IdMap, unsigned long> { - typedef VectorMap<_Graph, _Item, _IdMap, unsigned long> Map; + template + struct DefaultMapSelector<_Graph, _Item, _ItemIt, unsigned long> { + typedef VectorMap<_Graph, _Item, unsigned long> Map; }; // \todo handling long long type // float - template - struct DefaultMapSelector<_Graph, _Item, _ItemIt, _IdMap, float> { - typedef VectorMap<_Graph, _Item, _IdMap, float> Map; + template + struct DefaultMapSelector<_Graph, _Item, _ItemIt, float> { + typedef VectorMap<_Graph, _Item, float> Map; }; // double - template - struct DefaultMapSelector<_Graph, _Item, _ItemIt, _IdMap, double> { - typedef VectorMap<_Graph, _Item, _IdMap, double> Map; + template + struct DefaultMapSelector<_Graph, _Item, _ItemIt, double> { + typedef VectorMap<_Graph, _Item, double> Map; }; // long double - template - struct DefaultMapSelector<_Graph, _Item, _ItemIt, _IdMap, long double> { - typedef VectorMap<_Graph, _Item, _IdMap, long double> Map; + template + struct DefaultMapSelector<_Graph, _Item, _ItemIt, long double> { + typedef VectorMap<_Graph, _Item, long double> Map; }; // pointer - template - struct DefaultMapSelector<_Graph, _Item, _ItemIt, _IdMap, _Ptr*> { - typedef VectorMap<_Graph, _Item, _IdMap, _Ptr*> Map; + template + struct DefaultMapSelector<_Graph, _Item, _ItemIt, _Ptr*> { + typedef VectorMap<_Graph, _Item, _Ptr*> Map; }; @@ -140,19 +140,17 @@ template - class DefaultMap : public DefaultMapSelector<_Graph, _Item, _ItemIt, _IdMap, _Value>::Map { + class DefaultMap : public DefaultMapSelector<_Graph, _Item, _ItemIt, _Value>::Map { public: - typedef typename DefaultMapSelector<_Graph, _Item, _ItemIt, _IdMap, _Value>::Map Parent; - typedef DefaultMap<_Graph, _Item, _ItemIt, _IdMap, bool> Map; + typedef typename DefaultMapSelector<_Graph, _Item, _ItemIt, _Value>::Map Parent; + typedef DefaultMap<_Graph, _Item, _ItemIt, _Value> Map; typedef typename Parent::Graph Graph; - typedef typename Parent::Registry Registry; typedef typename Parent::ValueType ValueType; - DefaultMap(const Graph& _g, Registry& _r) : Parent(_g, _r) {} - DefaultMap(const Graph& _g, Registry& _r, const ValueType& _v) : Parent(_g, _r, _v) {} + DefaultMap(const Graph& _g) : Parent(_g) {} + DefaultMap(const Graph& _g, const ValueType& _v) : Parent(_g, _v) {} }; @@ -166,55 +164,48 @@ typedef typename Parent::Node Node; typedef typename Parent::NodeIt NodeIt; - typedef typename Parent::NodeIdMap NodeIdMap; - typedef typename Parent::NodeObserverRegistry NodeObserverRegistry; typedef typename Parent::Edge Edge; typedef typename Parent::EdgeIt EdgeIt; - typedef typename Parent::EdgeIdMap EdgeIdMap; - typedef typename Parent::EdgeObserverRegistry EdgeObserverRegistry; - template - class NodeMap : public DefaultMap { + class NodeMap : public DefaultMap { public: typedef DefaultMappableGraphExtender<_Base> Graph; typedef typename Graph::Node Node; typedef typename Graph::NodeIt NodeIt; - typedef typename Graph::NodeIdMap NodeIdMap; - typedef DefaultMap Parent; + typedef DefaultMap Parent; //typedef typename Parent::Graph Graph; typedef typename Parent::ValueType ValueType; - NodeMap(const Graph& g) - : Parent(g, g.getNodeObserverRegistry()) {} - NodeMap(const Graph& g, const ValueType& v) - : Parent(g, g.getNodeObserverRegistry(), v) {} + NodeMap(const Graph& _g) + : Parent(_g) {} + NodeMap(const Graph& _g, const ValueType& _v) + : Parent(_g, _v) {} }; template - class EdgeMap : public DefaultMap { + class EdgeMap : public DefaultMap { public: typedef DefaultMappableGraphExtender<_Base> Graph; typedef typename Graph::Edge Edge; typedef typename Graph::EdgeIt EdgeIt; - typedef typename Graph::EdgeIdMap EdgeIdMap; - typedef DefaultMap Parent; + typedef DefaultMap Parent; //typedef typename Parent::Graph Graph; typedef typename Parent::ValueType ValueType; - EdgeMap(const Graph& g) - : Parent(g, g.getEdgeObserverRegistry()) {} - EdgeMap(const Graph& g, const ValueType& v) - : Parent(g, g.getEdgeObserverRegistry(), v) {} + EdgeMap(const Graph& _g) + : Parent(_g) {} + EdgeMap(const Graph& _g, const ValueType& _v) + : Parent(_g, _v) {} }; diff -r b5fb023cdb7b -r 0f1044b7a3af src/lemon/erasable_graph_extender.h --- a/src/lemon/erasable_graph_extender.h Wed Nov 10 21:59:59 2004 +0000 +++ b/src/lemon/erasable_graph_extender.h Thu Nov 11 09:31:55 2004 +0000 @@ -32,12 +32,12 @@ Parent::firstIn(edge, node); } - Parent::getNodeObserverRegistry().erase(node); + Parent::getObserverRegistry(Node()).erase(node); Parent::erase(node); } void erase(const Edge& edge) { - Parent::getEdgeObserverRegistry().erase(edge); + Parent::getObserverRegistry(Edge()).erase(edge); Parent::erase(edge); } diff -r b5fb023cdb7b -r 0f1044b7a3af src/lemon/extendable_graph_extender.h --- a/src/lemon/extendable_graph_extender.h Wed Nov 10 21:59:59 2004 +0000 +++ b/src/lemon/extendable_graph_extender.h Thu Nov 11 09:31:55 2004 +0000 @@ -17,13 +17,13 @@ Node addNode() { Node node = Parent::addNode(); - Parent::getNodeObserverRegistry().add(node); + Parent::getObserverRegistry(Node()).add(node); return node; } Edge addEdge(const Node& from, const Node& to) { Edge edge = Parent::addEdge(from, to); - Parent::getEdgeObserverRegistry().add(edge); + Parent::getObserverRegistry(Edge()).add(edge); return edge; } diff -r b5fb023cdb7b -r 0f1044b7a3af src/lemon/full_graph.h --- a/src/lemon/full_graph.h Wed Nov 10 21:59:59 2004 +0000 +++ b/src/lemon/full_graph.h Thu Nov 11 09:31:55 2004 +0000 @@ -18,7 +18,6 @@ #define LEMON_FULL_GRAPH_H -#include #include #include #include @@ -70,12 +69,12 @@ /// Maximum node ID. ///\sa id(Node) - int maxNodeId() const { return NodeNum-1; } + int maxId(Node = INVALID) const { return NodeNum-1; } /// Maximum edge ID. /// Maximum edge ID. ///\sa id(Edge) - int maxEdgeId() const { return EdgeNum-1; } + int maxId(Edge = INVALID) const { return EdgeNum-1; } Node tail(Edge e) const { return e.id % NodeNum; } Node head(Edge e) const { return e.id / NodeNum; } @@ -188,8 +187,7 @@ typedef AlterableGraphExtender AlterableFullGraphBase; typedef IterableGraphExtender IterableFullGraphBase; - typedef IdMappableGraphExtender IdMappableFullGraphBase; - typedef DefaultMappableGraphExtender MappableFullGraphBase; + typedef DefaultMappableGraphExtender MappableFullGraphBase; ///A full graph class. diff -r b5fb023cdb7b -r 0f1044b7a3af src/lemon/idmappable_graph_extender.h --- a/src/lemon/idmappable_graph_extender.h Wed Nov 10 21:59:59 2004 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,52 +0,0 @@ -// -*- c++ -*- - -#ifndef LEMON_IDMAPPABLE_GRAPH_EXTENDER_H -#define LEMON_IDMAPPABLE_GRAPH_EXTENDER_H - - -namespace lemon { - - template - class IdMappableGraphExtender : public Base { - public: - - typedef IdMappableGraphExtender Graph; - typedef Base Parent; - - typedef typename Parent::Node Node; - typedef typename Parent::Edge Edge; - - - public: - - class NodeIdMap { - private: - const Graph* graph; - - public: - NodeIdMap(const Graph& g) : graph(&g) {} - - int operator[](const Node& node) const { return graph->id(node); } - - int maxId() const {return graph->maxNodeId(); } - - }; - - class EdgeIdMap { - private: - const Graph* graph; - - public: - EdgeIdMap(const Graph& g) : graph(&g) {} - - int operator[](const Edge& edge) const { return graph->id(edge); } - - int maxId() const {return graph->maxEdgeId(); } - - }; - - }; - -} - -#endif diff -r b5fb023cdb7b -r 0f1044b7a3af src/lemon/list_graph.h --- a/src/lemon/list_graph.h Wed Nov 10 21:59:59 2004 +0000 +++ b/src/lemon/list_graph.h Thu Nov 11 09:31:55 2004 +0000 @@ -25,8 +25,6 @@ #include #include -#include - #include #include @@ -105,13 +103,13 @@ /// Maximum node ID. ///\sa id(Node) - int maxNodeId() const { return nodes.size()-1; } + int maxId(Node = INVALID) const { return nodes.size()-1; } /// Maximum edge ID. /// Maximum edge ID. ///\sa id(Edge) - int maxEdgeId() const { return edges.size()-1; } + int maxId(Edge = INVALID) const { return edges.size()-1; } Node tail(Edge e) const { return edges[e.id].tail; } Node head(Edge e) const { return edges[e.id].head; } @@ -303,8 +301,7 @@ typedef AlterableGraphExtender AlterableListGraphBase; typedef IterableGraphExtender IterableListGraphBase; - typedef IdMappableGraphExtender IdMappableListGraphBase; - typedef DefaultMappableGraphExtender MappableListGraphBase; + typedef DefaultMappableGraphExtender MappableListGraphBase; typedef ExtendableGraphExtender ExtendableListGraphBase; typedef ClearableGraphExtender ClearableListGraphBase; typedef ErasableGraphExtender ErasableListGraphBase; diff -r b5fb023cdb7b -r 0f1044b7a3af src/lemon/map_bits.h --- a/src/lemon/map_bits.h Wed Nov 10 21:59:59 2004 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,67 +0,0 @@ -/* -*- C++ -*- - * src/lemon/map_bits.h - Part of LEMON, a generic C++ optimization library - * - * Copyright (C) 2004 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport - * (Egervary Combinatorial Optimization Research Group, EGRES). - * - * Permission to use, modify and distribute this software is granted - * provided that this copyright notice appears in all copies. For - * precise terms see the accompanying LICENSE file. - * - * This software is provided "AS IS" with no warranty of any kind, - * express or implied, and with no claim as to its suitability for any - * purpose. - * - */ - -#ifndef LEMON_MAP_BITS_H -#define LEMON_MAP_BITS_H - -///\ingroup graphmaps -///\file -///\brief Some utils to help implement maps. - -namespace lemon { - - - /// \addtogroup graphmaps - /// @{ - - /// Helper class to get information about the key type. - template - struct KeyInfo {}; - - template - struct KeyInfo { - static int maxId(const Graph& graph) { - return graph.maxNodeId(); - } - static int id(const Graph& graph, const typename Graph::Node& node) { - return graph.id(node); - } - }; - - template - struct KeyInfo { - static int maxId(const Graph& graph) { - return graph.maxEdgeId(); - } - static int id(const Graph& graph, const typename Graph::Edge& edge) { - return graph.id(edge); - } - }; - - template - struct KeyInfo { - static int maxId(const Graph& graph) { - return graph.maxSymEdgeId(); - } - static int id(const Graph& graph, const typename Graph::SymEdge& edge) { - return graph.id(edge); - } - }; - - /// @} -} - -#endif diff -r b5fb023cdb7b -r 0f1044b7a3af src/lemon/smart_graph.h --- a/src/lemon/smart_graph.h Wed Nov 10 21:59:59 2004 +0000 +++ b/src/lemon/smart_graph.h Thu Nov 11 09:31:55 2004 +0000 @@ -27,7 +27,6 @@ #include #include -#include #include #include #include @@ -91,12 +90,12 @@ /// Maximum node ID. ///\sa id(Node) - int maxNodeId() const { return nodes.size()-1; } + int maxId(Node = INVALID) const { return nodes.size()-1; } /// Maximum edge ID. /// Maximum edge ID. ///\sa id(Edge) - int maxEdgeId() const { return edges.size()-1; } + int maxId(Edge = INVALID) const { return edges.size()-1; } Node tail(Edge e) const { return edges[e.n].tail; } Node head(Edge e) const { return edges[e.n].head; } @@ -221,8 +220,7 @@ typedef AlterableGraphExtender AlterableSmartGraphBase; typedef IterableGraphExtender IterableSmartGraphBase; - typedef IdMappableGraphExtender IdMappableSmartGraphBase; - typedef DefaultMappableGraphExtender MappableSmartGraphBase; + typedef DefaultMappableGraphExtender MappableSmartGraphBase; typedef ExtendableGraphExtender ExtendableSmartGraphBase; typedef ClearableGraphExtender ClearableSmartGraphBase; @@ -239,7 +237,7 @@ ///\todo Some member functions could be \c static. /// ///\author Alpar Juttner - class SmartGraph :public ClearableSmartGraphBase { + class SmartGraph : public ClearableSmartGraphBase { public: /// Finds an edge between two nodes. diff -r b5fb023cdb7b -r 0f1044b7a3af src/lemon/vector_map.h --- a/src/lemon/vector_map.h Wed Nov 10 21:59:59 2004 +0000 +++ b/src/lemon/vector_map.h Thu Nov 11 09:31:55 2004 +0000 @@ -46,7 +46,6 @@ template class VectorMap : public AlterationObserverRegistry<_Item>::ObserverBase { public: @@ -56,8 +55,6 @@ /// The key type of the map. typedef _Item KeyType; /// The id map type of the map. - typedef _IdMap IdMap; - /// The registry type of the map. typedef AlterationObserverRegistry<_Item> Registry; /// The value type of the map. typedef _Value Value; @@ -93,8 +90,8 @@ /// It construates a map and attachs it into the registry. /// It adds all the items of the graph to the map. - VectorMap(const Graph& _g, Registry& _r) : graph(&_g) { - attach(_r); + VectorMap(const Graph& _g) : graph(&_g) { + attach(_g.getObserverRegistry(_Item())); build(); } @@ -103,15 +100,15 @@ /// It construates a map uses a given value to initialize the map. /// It adds all the items of the graph to the map. - VectorMap(const Graph& g, Registry& r, const Value& v) : graph(&g) { - attach(r); - container.resize(IdMap(*graph).maxId() + 1, v); + VectorMap(const Graph& _g, const Value& _v) : graph(&_g) { + attach(_g.getObserverRegistry(_Item())); + container.resize(graph->maxId(_Item()) + 1, _v); } - VectorMap(const VectorMap& copy) : graph(copy.getGraph()) { - if (copy.attached()) { - attach(*copy.getRegistry()); - container = copy.container; + VectorMap(const VectorMap& _copy) : graph(_copy.getGraph()) { + if (_copy.attached()) { + attach(*_copy.getRegistry()); + container = _copy.container; } } @@ -154,7 +151,7 @@ /// actual items of the graph. ReferenceType operator[](const KeyType& key) { - return container[IdMap(*graph)[key]]; + return container[graph->id(key)]; } /// The const subcript operator. @@ -163,7 +160,7 @@ /// actual items of the graph. ConstReferenceType operator[](const KeyType& key) const { - return container[IdMap(*graph)[key]]; + return container[graph->id(key)]; } @@ -182,7 +179,7 @@ /// and it overrides the add() member function of the observer base. void add(const KeyType& key) { - int id = IdMap(*graph)[key]; + int id = graph->id(key); if (id >= (int)container.size()) { container.resize(id + 1); } @@ -200,7 +197,7 @@ /// and it overrides the build() member function of the observer base. void build() { - container.resize(IdMap(*graph).maxId() + 1); + container.resize(graph->maxId(_Item()) + 1); } /// Clear the map. @@ -239,42 +236,40 @@ template - class NodeMap : public VectorMap { + class NodeMap : public VectorMap { public: typedef VectorMappableGraphExtender<_Base> Graph; typedef typename Graph::Node Node; - typedef typename Graph::NodeIdMap NodeIdMap; - typedef VectorMap Parent; + typedef VectorMap Parent; //typedef typename Parent::Graph Graph; typedef typename Parent::Value Value; NodeMap(const Graph& g) - : Parent(g, g.getNodeObserverRegistry()) {} + : Parent(g) {} NodeMap(const Graph& g, const Value& v) - : Parent(g, g.getNodeObserverRegistry(), v) {} + : Parent(g, v) {} }; template - class EdgeMap : public VectorMap { + class EdgeMap : public VectorMap { public: typedef VectorMappableGraphExtender<_Base> Graph; typedef typename Graph::Edge Edge; - typedef typename Graph::EdgeIdMap EdgeIdMap; - typedef VectorMap Parent; + typedef VectorMap Parent; //typedef typename Parent::Graph Graph; typedef typename Parent::Value Value; EdgeMap(const Graph& g) - : Parent(g, g.getEdgeObserverRegistry()) {} + : Parent(g) {} EdgeMap(const Graph& g, const Value& v) - : Parent(g, g.getEdgeObserverRegistry(), v) {} + : Parent(g, v) {} }; diff -r b5fb023cdb7b -r 0f1044b7a3af src/test/graph_test.cc --- a/src/test/graph_test.cc Wed Nov 10 21:59:59 2004 +0000 +++ b/src/test/graph_test.cc Thu Nov 11 09:31:55 2004 +0000 @@ -33,7 +33,6 @@ function_requires >(); - function_requires >(); function_requires >(); function_requires >();