[Lemon-commits] [lemon_svn] deba: r1368 - in hugo/trunk/src: lemon lemon/concept test
Lemon SVN
svn at lemon.cs.elte.hu
Mon Nov 6 20:44:53 CET 2006
Author: deba
Date: Thu Nov 11 10:31:55 2004
New Revision: 1368
Removed:
hugo/trunk/src/lemon/idmappable_graph_extender.h
hugo/trunk/src/lemon/map_bits.h
Modified:
hugo/trunk/src/lemon/Makefile.am
hugo/trunk/src/lemon/alteration_observer_registry.h
hugo/trunk/src/lemon/array_map.h
hugo/trunk/src/lemon/clearable_graph_extender.h
hugo/trunk/src/lemon/concept/graph_component.h
hugo/trunk/src/lemon/default_map.h
hugo/trunk/src/lemon/erasable_graph_extender.h
hugo/trunk/src/lemon/extendable_graph_extender.h
hugo/trunk/src/lemon/full_graph.h
hugo/trunk/src/lemon/list_graph.h
hugo/trunk/src/lemon/smart_graph.h
hugo/trunk/src/lemon/vector_map.h
hugo/trunk/src/test/graph_test.cc
Log:
maxNodeId() and maxEdgeId() changed to maxId(Node) and maxId(Edge)
getNodeObserverRegistry() and getEdgeObserverRegistry() changed to
getObserverRegistry(Node) and getObserverRegistry(Edge)
IdMappableGraphExtender erased
Modified: hugo/trunk/src/lemon/Makefile.am
==============================================================================
--- hugo/trunk/src/lemon/Makefile.am (original)
+++ hugo/trunk/src/lemon/Makefile.am Thu Nov 11 10:31:55 2004
@@ -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 \
Modified: hugo/trunk/src/lemon/alteration_observer_registry.h
==============================================================================
--- hugo/trunk/src/lemon/alteration_observer_registry.h (original)
+++ hugo/trunk/src/lemon/alteration_observer_registry.h Thu Nov 11 10:31:55 2004
@@ -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;
}
Modified: hugo/trunk/src/lemon/array_map.h
==============================================================================
--- hugo/trunk/src/lemon/array_map.h (original)
+++ hugo/trunk/src/lemon/array_map.h Thu Nov 11 10:31:55 2004
@@ -44,7 +44,6 @@
template <typename _Graph,
typename _Item,
typename _ItemIt,
- typename _IdMap,
typename _Value>
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 <typename _Value>
- class NodeMap : public ArrayMap<Graph, Node, NodeIt, NodeIdMap, _Value> {
+ class NodeMap : public ArrayMap<Graph, Node, NodeIt, _Value> {
public:
typedef ArrayMappableGraphExtender<_Base> Graph;
typedef typename Graph::Node Node;
typedef typename Graph::NodeIt NodeIt;
- typedef typename Graph::NodeIdMap NodeIdMap;
- typedef ArrayMap<Graph, Node, NodeIt, NodeIdMap, _Value> Parent;
+ typedef ArrayMap<Graph, Node, NodeIt, _Value> 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 <typename _Value>
- class EdgeMap : public ArrayMap<Graph, Edge, EdgeIt, EdgeIdMap, _Value> {
+ class EdgeMap : public ArrayMap<Graph, Edge, EdgeIt, _Value> {
public:
typedef ArrayMappableGraphExtender<_Base> Graph;
typedef typename Graph::Edge Edge;
typedef typename Graph::EdgeIt EdgeIt;
- typedef typename Graph::EdgeIdMap EdgeIdMap;
- typedef ArrayMap<Graph, Edge, EdgeIt, EdgeIdMap, _Value> Parent;
+ typedef ArrayMap<Graph, Edge, EdgeIt, _Value> 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) {}
};
Modified: hugo/trunk/src/lemon/clearable_graph_extender.h
==============================================================================
--- hugo/trunk/src/lemon/clearable_graph_extender.h (original)
+++ hugo/trunk/src/lemon/clearable_graph_extender.h Thu Nov 11 10:31:55 2004
@@ -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();
}
Modified: hugo/trunk/src/lemon/concept/graph_component.h
==============================================================================
--- hugo/trunk/src/lemon/concept/graph_component.h (original)
+++ hugo/trunk/src/lemon/concept/graph_component.h Thu Nov 11 10:31:55 2004
@@ -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<Graph> >();
- 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<Node, int> {
- public:
- NodeIdMap(const Graph&) {}
- int maxId() const { return -1;}
- };
-
- class EdgeIdMap : public ReadMap<Edge, int> {
- public:
- EdgeIdMap(const Graph&) {}
- int maxId() const { return -1;}
- };
-
- };
-
- template <typename Graph>
- struct IdMappableGraphComponentConcept {
- void constraints() {
- function_requires< BaseGraphComponentConcept<Graph> >();
- {
- typedef typename Graph::EdgeIdMap EdgeIdMap;
- function_requires<ReadMapConcept<EdgeIdMap> >();
- EdgeIdMap edge_map(graph);
- int n = edge_map.maxId();
- ignore_unused_variable_warning(n);
- }
- {
- typedef typename Graph::NodeIdMap NodeIdMap;
- function_requires<ReadMapConcept<NodeIdMap> >();
- NodeIdMap node_map(graph);
- int n = node_map.maxId();
- ignore_unused_variable_warning(n);
- }
- }
- Graph& graph;
- };
-
-
class MappableGraphComponent : virtual public BaseGraphComponent {
public:
Modified: hugo/trunk/src/lemon/default_map.h
==============================================================================
--- hugo/trunk/src/lemon/default_map.h (original)
+++ hugo/trunk/src/lemon/default_map.h Thu Nov 11 10:31:55 2004
@@ -42,97 +42,97 @@
- template <typename _Graph, typename _Item, typename _ItemIt, typename _IdMap, typename _Value>
+ template <typename _Graph, typename _Item, typename _ItemIt, typename _Value>
struct DefaultMapSelector {
- typedef ArrayMap<_Graph, _Item, _ItemIt, _IdMap, _Value> Map;
+ typedef ArrayMap<_Graph, _Item, _ItemIt, _Value> Map;
};
// bool
- template <typename _Graph, typename _Item, typename _ItemIt, typename _IdMap>
- struct DefaultMapSelector<_Graph, _Item, _ItemIt, _IdMap, bool> {
- typedef VectorMap<_Graph, _Item, _IdMap, bool> Map;
+ template <typename _Graph, typename _Item, typename _ItemIt>
+ struct DefaultMapSelector<_Graph, _Item, _ItemIt, bool> {
+ typedef VectorMap<_Graph, _Item, bool> Map;
};
// char
- template <typename _Graph, typename _Item, typename _ItemIt, typename _IdMap>
- struct DefaultMapSelector<_Graph, _Item, _ItemIt, _IdMap, char> {
- typedef VectorMap<_Graph, _Item, _IdMap, char> Map;
+ template <typename _Graph, typename _Item, typename _ItemIt>
+ struct DefaultMapSelector<_Graph, _Item, _ItemIt, char> {
+ typedef VectorMap<_Graph, _Item, char> Map;
};
- template <typename _Graph, typename _Item, typename _ItemIt, typename _IdMap>
- struct DefaultMapSelector<_Graph, _Item, _ItemIt, _IdMap, signed char> {
- typedef VectorMap<_Graph, _Item, _IdMap, signed char> Map;
+ template <typename _Graph, typename _Item, typename _ItemIt>
+ struct DefaultMapSelector<_Graph, _Item, _ItemIt, signed char> {
+ typedef VectorMap<_Graph, _Item, signed char> Map;
};
- template <typename _Graph, typename _Item, typename _ItemIt, typename _IdMap>
- struct DefaultMapSelector<_Graph, _Item, _ItemIt, _IdMap, unsigned char> {
- typedef VectorMap<_Graph, _Item, _IdMap, unsigned char> Map;
+ template <typename _Graph, typename _Item, typename _ItemIt>
+ struct DefaultMapSelector<_Graph, _Item, _ItemIt, unsigned char> {
+ typedef VectorMap<_Graph, _Item, unsigned char> Map;
};
// int
- template <typename _Graph, typename _Item, typename _ItemIt, typename _IdMap>
- struct DefaultMapSelector<_Graph, _Item, _ItemIt, _IdMap, signed int> {
- typedef VectorMap<_Graph, _Item, _IdMap, signed int> Map;
+ template <typename _Graph, typename _Item, typename _ItemIt>
+ struct DefaultMapSelector<_Graph, _Item, _ItemIt, signed int> {
+ typedef VectorMap<_Graph, _Item, signed int> Map;
};
- template <typename _Graph, typename _Item, typename _ItemIt, typename _IdMap>
- struct DefaultMapSelector<_Graph, _Item, _ItemIt, _IdMap, unsigned int> {
- typedef VectorMap<_Graph, _Item, _IdMap, unsigned int> Map;
+ template <typename _Graph, typename _Item, typename _ItemIt>
+ struct DefaultMapSelector<_Graph, _Item, _ItemIt, unsigned int> {
+ typedef VectorMap<_Graph, _Item, unsigned int> Map;
};
// short
- template <typename _Graph, typename _Item, typename _ItemIt, typename _IdMap>
- struct DefaultMapSelector<_Graph, _Item, _ItemIt, _IdMap, signed short> {
- typedef VectorMap<_Graph, _Item, _IdMap, signed short> Map;
+ template <typename _Graph, typename _Item, typename _ItemIt>
+ struct DefaultMapSelector<_Graph, _Item, _ItemIt, signed short> {
+ typedef VectorMap<_Graph, _Item, signed short> Map;
};
- template <typename _Graph, typename _Item, typename _ItemIt, typename _IdMap>
- struct DefaultMapSelector<_Graph, _Item, _ItemIt, _IdMap, unsigned short> {
- typedef VectorMap<_Graph, _Item, _IdMap, unsigned short> Map;
+ template <typename _Graph, typename _Item, typename _ItemIt>
+ struct DefaultMapSelector<_Graph, _Item, _ItemIt, unsigned short> {
+ typedef VectorMap<_Graph, _Item, unsigned short> Map;
};
// long
- template <typename _Graph, typename _Item, typename _ItemIt, typename _IdMap>
- struct DefaultMapSelector<_Graph, _Item, _ItemIt, _IdMap, signed long> {
- typedef VectorMap<_Graph, _Item, _IdMap, signed long> Map;
+ template <typename _Graph, typename _Item, typename _ItemIt>
+ struct DefaultMapSelector<_Graph, _Item, _ItemIt, signed long> {
+ typedef VectorMap<_Graph, _Item, signed long> Map;
};
- template <typename _Graph, typename _Item, typename _ItemIt, typename _IdMap>
- struct DefaultMapSelector<_Graph, _Item, _ItemIt, _IdMap, unsigned long> {
- typedef VectorMap<_Graph, _Item, _IdMap, unsigned long> Map;
+ template <typename _Graph, typename _Item, typename _ItemIt>
+ struct DefaultMapSelector<_Graph, _Item, _ItemIt, unsigned long> {
+ typedef VectorMap<_Graph, _Item, unsigned long> Map;
};
// \todo handling long long type
// float
- template <typename _Graph, typename _Item, typename _ItemIt, typename _IdMap>
- struct DefaultMapSelector<_Graph, _Item, _ItemIt, _IdMap, float> {
- typedef VectorMap<_Graph, _Item, _IdMap, float> Map;
+ template <typename _Graph, typename _Item, typename _ItemIt>
+ struct DefaultMapSelector<_Graph, _Item, _ItemIt, float> {
+ typedef VectorMap<_Graph, _Item, float> Map;
};
// double
- template <typename _Graph, typename _Item, typename _ItemIt, typename _IdMap>
- struct DefaultMapSelector<_Graph, _Item, _ItemIt, _IdMap, double> {
- typedef VectorMap<_Graph, _Item, _IdMap, double> Map;
+ template <typename _Graph, typename _Item, typename _ItemIt>
+ struct DefaultMapSelector<_Graph, _Item, _ItemIt, double> {
+ typedef VectorMap<_Graph, _Item, double> Map;
};
// long double
- template <typename _Graph, typename _Item, typename _ItemIt, typename _IdMap>
- struct DefaultMapSelector<_Graph, _Item, _ItemIt, _IdMap, long double> {
- typedef VectorMap<_Graph, _Item, _IdMap, long double> Map;
+ template <typename _Graph, typename _Item, typename _ItemIt>
+ struct DefaultMapSelector<_Graph, _Item, _ItemIt, long double> {
+ typedef VectorMap<_Graph, _Item, long double> Map;
};
// pointer
- template <typename _Graph, typename _Item, typename _ItemIt, typename _IdMap, typename _Ptr>
- struct DefaultMapSelector<_Graph, _Item, _ItemIt, _IdMap, _Ptr*> {
- typedef VectorMap<_Graph, _Item, _IdMap, _Ptr*> Map;
+ template <typename _Graph, typename _Item, typename _ItemIt, typename _Ptr>
+ struct DefaultMapSelector<_Graph, _Item, _ItemIt, _Ptr*> {
+ typedef VectorMap<_Graph, _Item, _Ptr*> Map;
};
@@ -140,19 +140,17 @@
template <typename _Graph,
typename _Item,
typename _ItemIt,
- typename _IdMap,
typename _Value>
- 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 <typename _Value>
- class NodeMap : public DefaultMap<Graph, Node, NodeIt, NodeIdMap, _Value> {
+ class NodeMap : public DefaultMap<Graph, Node, NodeIt, _Value> {
public:
typedef DefaultMappableGraphExtender<_Base> Graph;
typedef typename Graph::Node Node;
typedef typename Graph::NodeIt NodeIt;
- typedef typename Graph::NodeIdMap NodeIdMap;
- typedef DefaultMap<Graph, Node, NodeIt, NodeIdMap, _Value> Parent;
+ typedef DefaultMap<Graph, Node, NodeIt, _Value> 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 <typename _Value>
- class EdgeMap : public DefaultMap<Graph, Edge, EdgeIt, EdgeIdMap, _Value> {
+ class EdgeMap : public DefaultMap<Graph, Edge, EdgeIt, _Value> {
public:
typedef DefaultMappableGraphExtender<_Base> Graph;
typedef typename Graph::Edge Edge;
typedef typename Graph::EdgeIt EdgeIt;
- typedef typename Graph::EdgeIdMap EdgeIdMap;
- typedef DefaultMap<Graph, Edge, EdgeIt, EdgeIdMap, _Value> Parent;
+ typedef DefaultMap<Graph, Edge, EdgeIt, _Value> 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) {}
};
Modified: hugo/trunk/src/lemon/erasable_graph_extender.h
==============================================================================
--- hugo/trunk/src/lemon/erasable_graph_extender.h (original)
+++ hugo/trunk/src/lemon/erasable_graph_extender.h Thu Nov 11 10:31:55 2004
@@ -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);
}
Modified: hugo/trunk/src/lemon/extendable_graph_extender.h
==============================================================================
--- hugo/trunk/src/lemon/extendable_graph_extender.h (original)
+++ hugo/trunk/src/lemon/extendable_graph_extender.h Thu Nov 11 10:31:55 2004
@@ -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;
}
Modified: hugo/trunk/src/lemon/full_graph.h
==============================================================================
--- hugo/trunk/src/lemon/full_graph.h (original)
+++ hugo/trunk/src/lemon/full_graph.h Thu Nov 11 10:31:55 2004
@@ -18,7 +18,6 @@
#define LEMON_FULL_GRAPH_H
-#include <lemon/idmappable_graph_extender.h>
#include <lemon/iterable_graph_extender.h>
#include <lemon/alteration_observer_registry.h>
#include <lemon/default_map.h>
@@ -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<FullGraphBase> AlterableFullGraphBase;
typedef IterableGraphExtender<AlterableFullGraphBase> IterableFullGraphBase;
- typedef IdMappableGraphExtender<IterableFullGraphBase> IdMappableFullGraphBase;
- typedef DefaultMappableGraphExtender<IdMappableFullGraphBase> MappableFullGraphBase;
+ typedef DefaultMappableGraphExtender<IterableFullGraphBase> MappableFullGraphBase;
///A full graph class.
Modified: hugo/trunk/src/lemon/list_graph.h
==============================================================================
--- hugo/trunk/src/lemon/list_graph.h (original)
+++ hugo/trunk/src/lemon/list_graph.h Thu Nov 11 10:31:55 2004
@@ -25,8 +25,6 @@
#include <lemon/clearable_graph_extender.h>
#include <lemon/extendable_graph_extender.h>
-#include <lemon/idmappable_graph_extender.h>
-
#include <lemon/iterable_graph_extender.h>
#include <lemon/alteration_observer_registry.h>
@@ -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<ListGraphBase> AlterableListGraphBase;
typedef IterableGraphExtender<AlterableListGraphBase> IterableListGraphBase;
- typedef IdMappableGraphExtender<IterableListGraphBase> IdMappableListGraphBase;
- typedef DefaultMappableGraphExtender<IdMappableListGraphBase> MappableListGraphBase;
+ typedef DefaultMappableGraphExtender<IterableListGraphBase> MappableListGraphBase;
typedef ExtendableGraphExtender<MappableListGraphBase> ExtendableListGraphBase;
typedef ClearableGraphExtender<ExtendableListGraphBase> ClearableListGraphBase;
typedef ErasableGraphExtender<ClearableListGraphBase> ErasableListGraphBase;
Modified: hugo/trunk/src/lemon/smart_graph.h
==============================================================================
--- hugo/trunk/src/lemon/smart_graph.h (original)
+++ hugo/trunk/src/lemon/smart_graph.h Thu Nov 11 10:31:55 2004
@@ -27,7 +27,6 @@
#include <lemon/clearable_graph_extender.h>
#include <lemon/extendable_graph_extender.h>
-#include <lemon/idmappable_graph_extender.h>
#include <lemon/iterable_graph_extender.h>
#include <lemon/alteration_observer_registry.h>
#include <lemon/default_map.h>
@@ -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<SmartGraphBase> AlterableSmartGraphBase;
typedef IterableGraphExtender<AlterableSmartGraphBase> IterableSmartGraphBase;
- typedef IdMappableGraphExtender<IterableSmartGraphBase> IdMappableSmartGraphBase;
- typedef DefaultMappableGraphExtender<IdMappableSmartGraphBase> MappableSmartGraphBase;
+ typedef DefaultMappableGraphExtender<IterableSmartGraphBase> MappableSmartGraphBase;
typedef ExtendableGraphExtender<MappableSmartGraphBase> ExtendableSmartGraphBase;
typedef ClearableGraphExtender<ExtendableSmartGraphBase> 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.
Modified: hugo/trunk/src/lemon/vector_map.h
==============================================================================
--- hugo/trunk/src/lemon/vector_map.h (original)
+++ hugo/trunk/src/lemon/vector_map.h Thu Nov 11 10:31:55 2004
@@ -46,7 +46,6 @@
template <typename _Graph,
typename _Item,
- typename _IdMap,
typename _Value>
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 <typename _Value>
- class NodeMap : public VectorMap<Graph, Node, NodeIdMap, _Value> {
+ class NodeMap : public VectorMap<Graph, Node, _Value> {
public:
typedef VectorMappableGraphExtender<_Base> Graph;
typedef typename Graph::Node Node;
- typedef typename Graph::NodeIdMap NodeIdMap;
- typedef VectorMap<Graph, Node, NodeIdMap, _Value> Parent;
+ typedef VectorMap<Graph, Node, _Value> 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 <typename _Value>
- class EdgeMap : public VectorMap<Graph, Edge, EdgeIdMap, _Value> {
+ class EdgeMap : public VectorMap<Graph, Edge, _Value> {
public:
typedef VectorMappableGraphExtender<_Base> Graph;
typedef typename Graph::Edge Edge;
- typedef typename Graph::EdgeIdMap EdgeIdMap;
- typedef VectorMap<Graph, Edge, EdgeIdMap, _Value> Parent;
+ typedef VectorMap<Graph, Edge, _Value> 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) {}
};
Modified: hugo/trunk/src/test/graph_test.cc
==============================================================================
--- hugo/trunk/src/test/graph_test.cc (original)
+++ hugo/trunk/src/test/graph_test.cc Thu Nov 11 10:31:55 2004
@@ -33,7 +33,6 @@
function_requires<IterableGraphComponentConcept<IterableGraphComponent> >();
- function_requires<IdMappableGraphComponentConcept<IdMappableGraphComponent> >();
function_requires<MappableGraphComponentConcept<MappableGraphComponent> >();
function_requires<ExtendableGraphComponentConcept<ExtendableGraphComponent> >();
More information about the Lemon-commits
mailing list