[Lemon-commits] Peter Kovacs: Standard graph maps are required t...
Lemon HG
hg at lemon.cs.elte.hu
Tue Apr 14 11:42:46 CEST 2009
details: http://lemon.cs.elte.hu/hg/lemon/rev/2313edd0db0b
changeset: 612:2313edd0db0b
user: Peter Kovacs <kpeter [at] inf.elte.hu>
date: Tue Apr 14 10:34:12 2009 +0200
description:
Standard graph maps are required to be reference maps (#190)
diffstat:
lemon/bits/graph_adaptor_extender.h | 2 --
lemon/bits/map_extender.h | 4 ++++
lemon/concepts/digraph.h | 19 ++++++++++---------
lemon/concepts/graph.h | 31 ++++++++++++++++---------------
lemon/concepts/graph_components.h | 16 ++++++++++++++--
5 files changed, 44 insertions(+), 28 deletions(-)
diffs (246 lines):
diff --git a/lemon/bits/graph_adaptor_extender.h b/lemon/bits/graph_adaptor_extender.h
--- a/lemon/bits/graph_adaptor_extender.h
+++ b/lemon/bits/graph_adaptor_extender.h
@@ -22,8 +22,6 @@
#include <lemon/core.h>
#include <lemon/error.h>
-#include <lemon/bits/default_map.h>
-
namespace lemon {
template <typename _Digraph>
diff --git a/lemon/bits/map_extender.h b/lemon/bits/map_extender.h
--- a/lemon/bits/map_extender.h
+++ b/lemon/bits/map_extender.h
@@ -47,6 +47,8 @@
typedef typename Parent::Key Key;
typedef typename Parent::Value Value;
+ typedef typename Parent::Reference Reference;
+ typedef typename Parent::ConstReference ConstReference;
class MapIt;
class ConstMapIt;
@@ -187,6 +189,8 @@
typedef typename Parent::Key Key;
typedef typename Parent::Value Value;
+ typedef typename Parent::Reference Reference;
+ typedef typename Parent::ConstReference ConstReference;
class MapIt;
class ConstMapIt;
diff --git a/lemon/concepts/digraph.h b/lemon/concepts/digraph.h
--- a/lemon/concepts/digraph.h
+++ b/lemon/concepts/digraph.h
@@ -421,12 +421,11 @@
/// Gives back the opposite node on the given arc.
Node oppositeNode(const Node&, const Arc&) const { return INVALID; }
- /// \brief Read write map of the nodes to type \c T.
+ /// \brief Reference map of the nodes to type \c T.
///
- /// ReadWrite map of the nodes to type \c T.
- /// \sa Reference
+ /// Reference map of the nodes to type \c T.
template<class T>
- class NodeMap : public ReadWriteMap< Node, T > {
+ class NodeMap : public ReferenceMap<Node, T, T&, const T&> {
public:
///\e
@@ -436,7 +435,8 @@
private:
///Copy constructor
- NodeMap(const NodeMap& nm) : ReadWriteMap< Node, T >(nm) { }
+ NodeMap(const NodeMap& nm) :
+ ReferenceMap<Node, T, T&, const T&>(nm) { }
///Assignment operator
template <typename CMap>
NodeMap& operator=(const CMap&) {
@@ -445,12 +445,11 @@
}
};
- /// \brief Read write map of the arcs to type \c T.
+ /// \brief Reference map of the arcs to type \c T.
///
/// Reference map of the arcs to type \c T.
- /// \sa Reference
template<class T>
- class ArcMap : public ReadWriteMap<Arc,T> {
+ class ArcMap : public ReferenceMap<Arc, T, T&, const T&> {
public:
///\e
@@ -459,7 +458,8 @@
ArcMap(const Digraph&, T) { }
private:
///Copy constructor
- ArcMap(const ArcMap& em) : ReadWriteMap<Arc,T>(em) { }
+ ArcMap(const ArcMap& em) :
+ ReferenceMap<Arc, T, T&, const T&>(em) { }
///Assignment operator
template <typename CMap>
ArcMap& operator=(const CMap&) {
@@ -471,6 +471,7 @@
template <typename _Digraph>
struct Constraints {
void constraints() {
+ checkConcept<BaseDigraphComponent, _Digraph>();
checkConcept<IterableDigraphComponent<>, _Digraph>();
checkConcept<IDableDigraphComponent<>, _Digraph>();
checkConcept<MappableDigraphComponent<>, _Digraph>();
diff --git a/lemon/concepts/graph.h b/lemon/concepts/graph.h
--- a/lemon/concepts/graph.h
+++ b/lemon/concepts/graph.h
@@ -497,12 +497,11 @@
InArcIt& operator++() { return *this; }
};
- /// \brief Read write map of the nodes to type \c T.
+ /// \brief Reference map of the nodes to type \c T.
///
- /// ReadWrite map of the nodes to type \c T.
- /// \sa Reference
+ /// Reference map of the nodes to type \c T.
template<class T>
- class NodeMap : public ReadWriteMap< Node, T >
+ class NodeMap : public ReferenceMap<Node, T, T&, const T&>
{
public:
@@ -513,7 +512,8 @@
private:
///Copy constructor
- NodeMap(const NodeMap& nm) : ReadWriteMap< Node, T >(nm) { }
+ NodeMap(const NodeMap& nm) :
+ ReferenceMap<Node, T, T&, const T&>(nm) { }
///Assignment operator
template <typename CMap>
NodeMap& operator=(const CMap&) {
@@ -522,12 +522,11 @@
}
};
- /// \brief Read write map of the directed arcs to type \c T.
+ /// \brief Reference map of the arcs to type \c T.
///
- /// Reference map of the directed arcs to type \c T.
- /// \sa Reference
+ /// Reference map of the arcs to type \c T.
template<class T>
- class ArcMap : public ReadWriteMap<Arc,T>
+ class ArcMap : public ReferenceMap<Arc, T, T&, const T&>
{
public:
@@ -537,7 +536,8 @@
ArcMap(const Graph&, T) { }
private:
///Copy constructor
- ArcMap(const ArcMap& em) : ReadWriteMap<Arc,T>(em) { }
+ ArcMap(const ArcMap& em) :
+ ReferenceMap<Arc, T, T&, const T&>(em) { }
///Assignment operator
template <typename CMap>
ArcMap& operator=(const CMap&) {
@@ -546,12 +546,11 @@
}
};
- /// Read write map of the edges to type \c T.
+ /// Reference map of the edges to type \c T.
- /// Reference map of the arcs to type \c T.
- /// \sa Reference
+ /// Reference map of the edges to type \c T.
template<class T>
- class EdgeMap : public ReadWriteMap<Edge,T>
+ class EdgeMap : public ReferenceMap<Edge, T, T&, const T&>
{
public:
@@ -561,7 +560,8 @@
EdgeMap(const Graph&, T) { }
private:
///Copy constructor
- EdgeMap(const EdgeMap& em) : ReadWriteMap<Edge,T>(em) {}
+ EdgeMap(const EdgeMap& em) :
+ ReferenceMap<Edge, T, T&, const T&>(em) {}
///Assignment operator
template <typename CMap>
EdgeMap& operator=(const CMap&) {
@@ -748,6 +748,7 @@
template <typename _Graph>
struct Constraints {
void constraints() {
+ checkConcept<BaseGraphComponent, _Graph>();
checkConcept<IterableGraphComponent<>, _Graph>();
checkConcept<IDableGraphComponent<>, _Graph>();
checkConcept<MappableGraphComponent<>, _Graph>();
diff --git a/lemon/concepts/graph_components.h b/lemon/concepts/graph_components.h
--- a/lemon/concepts/graph_components.h
+++ b/lemon/concepts/graph_components.h
@@ -988,8 +988,9 @@
/// This class describes the concept of standard graph maps, i.e.
/// the \c NodeMap, \c ArcMap and \c EdgeMap subtypes of digraph and
/// graph types, which can be used for associating data to graph items.
+ /// The standard graph maps must conform to the ReferenceMap concept.
template <typename GR, typename K, typename V>
- class GraphMap : public ReadWriteMap<K, V> {
+ class GraphMap : public ReferenceMap<K, V, V&, const V&> {
public:
typedef ReadWriteMap<K, V> Parent;
@@ -1000,6 +1001,13 @@
typedef K Key;
/// The value type of the map.
typedef V Value;
+ /// The reference type of the map.
+ typedef Value& Reference;
+ /// The const reference type of the map.
+ typedef const Value& ConstReference;
+
+ // The reference map tag.
+ typedef True ReferenceMapTag;
/// \brief Construct a new map.
///
@@ -1031,7 +1039,8 @@
template<typename _Map>
struct Constraints {
void constraints() {
- checkConcept<ReadWriteMap<Key, Value>, _Map >();
+ checkConcept
+ <ReferenceMap<Key, Value, Value&, const Value&>, _Map>();
_Map m1(g);
_Map m2(g,t);
@@ -1073,6 +1082,7 @@
/// \brief Standard graph map for the nodes.
///
/// Standard graph map for the nodes.
+ /// It conforms to the ReferenceMap concept.
template <typename V>
class NodeMap : public GraphMap<MappableDigraphComponent, Node, V> {
public:
@@ -1110,6 +1120,7 @@
/// \brief Standard graph map for the arcs.
///
/// Standard graph map for the arcs.
+ /// It conforms to the ReferenceMap concept.
template <typename V>
class ArcMap : public GraphMap<MappableDigraphComponent, Arc, V> {
public:
@@ -1207,6 +1218,7 @@
/// \brief Standard graph map for the edges.
///
/// Standard graph map for the edges.
+ /// It conforms to the ReferenceMap concept.
template <typename V>
class EdgeMap : public GraphMap<MappableGraphComponent, Edge, V> {
public:
More information about the Lemon-commits
mailing list