[Lemon-commits] [lemon_svn] alpar: r988 - hugo/trunk/src/hugo/skeletons
Lemon SVN
svn at lemon.cs.elte.hu
Mon Nov 6 20:42:35 CET 2006
Author: alpar
Date: Thu Jul 22 21:59:18 2004
New Revision: 988
Modified:
hugo/trunk/src/hugo/skeletons/graph.h
hugo/trunk/src/hugo/skeletons/maps.h
Log:
Skeletons have been simplified.
"Optional features" have been deleted.
Map skeletons have been renamed.
Modified: hugo/trunk/src/hugo/skeletons/graph.h
==============================================================================
--- hugo/trunk/src/hugo/skeletons/graph.h (original)
+++ hugo/trunk/src/hugo/skeletons/graph.h Thu Jul 22 21:59:18 2004
@@ -6,376 +6,365 @@
///\brief Declaration of GraphSkeleton.
#include <hugo/invalid.h>
+#include <hugo/skeletons/maps.h>
/// The namespace of HugoLib
namespace hugo {
+ namespace skeleton {
+
+ // @defgroup empty_graph The GraphSkeleton class
+ // @{
- // @defgroup empty_graph The GraphSkeleton class
- // @{
-
- /// An empty graph class.
+ /// An empty static graph class.
- /// This class provides all the common features of a graph structure,
- /// however completely without implementations and real data structures
- /// behind the interface.
- /// All graph algorithms should compile with this class, but it will not
- /// run properly, of course.
- ///
- /// It can be used for checking the interface compatibility,
- /// or it can serve as a skeleton of a new graph structure.
- ///
- /// Also, you will find here the full documentation of a certain graph
- /// feature, the documentation of a real graph imlementation
- /// like @ref ListGraph or
- /// @ref SmartGraph will just refer to this structure.
- class GraphSkeleton
- {
- public:
- /// Defalult constructor.
- GraphSkeleton() {}
- ///Copy consructor.
-
- ///\todo It is not clear, what we expect from a copy constructor.
- ///E.g. How to assign the nodes/edges to each other? What about maps?
- GraphSkeleton(const GraphSkeleton &G) {}
-
- /// The base type of the node iterators.
-
- /// This is the base type of each node iterators,
- /// thus each kind of node iterator will convert to this.
- class Node {
+ /// This class provides all the common features of a graph structure,
+ /// however completely without implementations and real data structures
+ /// behind the interface.
+ /// All graph algorithms should compile with this class, but it will not
+ /// run properly, of course.
+ ///
+ /// It can be used for checking the interface compatibility,
+ /// or it can serve as a skeleton of a new graph structure.
+ ///
+ /// Also, you will find here the full documentation of a certain graph
+ /// feature, the documentation of a real graph imlementation
+ /// like @ref ListGraph or
+ /// @ref SmartGraph will just refer to this structure.
+ class StaticGraphSkeleton
+ {
public:
- /// @warning The default constructor sets the iterator
- /// to an undefined value.
- Node() {} //FIXME
- /// Invalid constructor \& conversion.
-
- /// This constructor initializes the iterator to be invalid.
- /// \sa Invalid for more details.
-
- Node(Invalid) {}
- //Node(const Node &) {}
-
- /// Two iterators are equal if and only if they point to the
- /// same object or both are invalid.
- bool operator==(Node) const { return true; }
-
- /// \sa \ref operator==(Node n)
- ///
- bool operator!=(Node) const { return true; }
+ /// Defalult constructor.
+ StaticGraphSkeleton() {}
+ ///Copy consructor.
+
+ ///\todo It is not clear, what we expect from a copy constructor.
+ ///E.g. How to assign the nodes/edges to each other? What about maps?
+ StaticGraphSkeleton(const StaticGraphSkeleton &G) {}
+
+ /// The base type of the node iterators.
+
+ /// This is the base type of each node iterators,
+ /// thus each kind of node iterator will convert to this.
+ class Node {
+ public:
+ /// @warning The default constructor sets the iterator
+ /// to an undefined value.
+ Node() {} //FIXME
+ /// Invalid constructor \& conversion.
+
+ /// This constructor initializes the iterator to be invalid.
+ /// \sa Invalid for more details.
+
+ Node(Invalid) {}
+ //Node(const Node &) {}
+
+ /// Two iterators are equal if and only if they point to the
+ /// same object or both are invalid.
+ bool operator==(Node) const { return true; }
+
+ /// \sa \ref operator==(Node n)
+ ///
+ bool operator!=(Node) const { return true; }
- bool operator<(Node) const { return true; }
- };
+ bool operator<(Node) const { return true; }
+ };
- /// This iterator goes through each node.
+ /// This iterator goes through each node.
- /// This iterator goes through each node.
- /// Its usage is quite simple, for example you can count the number
- /// of nodes in graph \c G of type \c Graph like this:
- /// \code
- ///int count=0;
- ///for(Graph::NodeIt n(G);G.valid(n);G.next(n)) count++;
- /// \endcode
- class NodeIt : public Node {
- public:
- /// @warning The default constructor sets the iterator
- /// to an undefined value.
- NodeIt() {} //FIXME
- /// Invalid constructor \& conversion.
-
- /// Initialize the iterator to be invalid
- /// \sa Invalid for more details.
- NodeIt(Invalid) {}
- /// Sets the iterator to the first node of \c G.
- NodeIt(const GraphSkeleton &) {}
- /// @warning The default constructor sets the iterator
- /// to an undefined value.
- NodeIt(const NodeIt &n) : Node(n) {}
- };
+ /// This iterator goes through each node.
+ /// Its usage is quite simple, for example you can count the number
+ /// of nodes in graph \c G of type \c Graph like this:
+ /// \code
+ ///int count=0;
+ ///for(Graph::NodeIt n(G);G.valid(n);G.next(n)) count++;
+ /// \endcode
+ class NodeIt : public Node {
+ public:
+ /// @warning The default constructor sets the iterator
+ /// to an undefined value.
+ NodeIt() {} //FIXME
+ /// Invalid constructor \& conversion.
+
+ /// Initialize the iterator to be invalid
+ /// \sa Invalid for more details.
+ NodeIt(Invalid) {}
+ /// Sets the iterator to the first node of \c G.
+ NodeIt(const StaticGraphSkeleton &) {}
+ /// @warning The default constructor sets the iterator
+ /// to an undefined value.
+ NodeIt(const NodeIt &n) : Node(n) {}
+ };
- /// The base type of the edge iterators.
- class Edge {
- public:
- /// @warning The default constructor sets the iterator
- /// to an undefined value.
- Edge() {} //FIXME
- /// Initialize the iterator to be invalid
- Edge(Invalid) {}
- /// Two iterators are equal if and only if they point to the
- /// same object or both are invalid.
- bool operator==(Edge) const { return true; }
- bool operator!=(Edge) const { return true; }
- bool operator<(Edge) const { return true; }
- };
+ /// The base type of the edge iterators.
+ class Edge {
+ public:
+ /// @warning The default constructor sets the iterator
+ /// to an undefined value.
+ Edge() {} //FIXME
+ /// Initialize the iterator to be invalid
+ Edge(Invalid) {}
+ /// Two iterators are equal if and only if they point to the
+ /// same object or both are invalid.
+ bool operator==(Edge) const { return true; }
+ bool operator!=(Edge) const { return true; }
+ bool operator<(Edge) const { return true; }
+ };
- /// This iterator goes trough the outgoing edges of a node.
+ /// This iterator goes trough the outgoing edges of a node.
- /// This iterator goes trough the \e outgoing edges of a certain node
- /// of a graph.
- /// Its usage is quite simple, for example you can count the number
- /// of outgoing edges of a node \c n
- /// in graph \c G of type \c Graph as follows.
- /// \code
- ///int count=0;
- ///for(Graph::OutEdgeIt e(G,n);G.valid(e);G.next(e)) count++;
- /// \endcode
+ /// This iterator goes trough the \e outgoing edges of a certain node
+ /// of a graph.
+ /// Its usage is quite simple, for example you can count the number
+ /// of outgoing edges of a node \c n
+ /// in graph \c G of type \c Graph as follows.
+ /// \code
+ ///int count=0;
+ ///for(Graph::OutEdgeIt e(G,n);G.valid(e);G.next(e)) count++;
+ /// \endcode
- class OutEdgeIt : public Edge {
- public:
- /// @warning The default constructor sets the iterator
- /// to an undefined value.
- OutEdgeIt() {}
- /// Initialize the iterator to be invalid
- OutEdgeIt(Invalid) {}
- /// This constructor sets the iterator to first outgoing edge.
+ class OutEdgeIt : public Edge {
+ public:
+ /// @warning The default constructor sets the iterator
+ /// to an undefined value.
+ OutEdgeIt() {}
+ /// Initialize the iterator to be invalid
+ OutEdgeIt(Invalid) {}
+ /// This constructor sets the iterator to first outgoing edge.
- /// This constructor set the iterator to the first outgoing edge of
- /// node
- ///@param n the node
- ///@param G the graph
- OutEdgeIt(const GraphSkeleton &, Node) {}
- };
-
- /// This iterator goes trough the incoming edges of a node.
-
- /// This iterator goes trough the \e incoming edges of a certain node
- /// of a graph.
- /// Its usage is quite simple, for example you can count the number
- /// of outgoing edges of a node \c n
- /// in graph \c G of type \c Graph as follows.
- /// \code
- ///int count=0;
- ///for(Graph::InEdgeIt e(G,n);G.valid(e);G.next(e)) count++;
- /// \endcode
+ /// This constructor set the iterator to the first outgoing edge of
+ /// node
+ ///@param n the node
+ ///@param G the graph
+ OutEdgeIt(const StaticGraphSkeleton &, Node) {}
+ };
+
+ /// This iterator goes trough the incoming edges of a node.
+
+ /// This iterator goes trough the \e incoming edges of a certain node
+ /// of a graph.
+ /// Its usage is quite simple, for example you can count the number
+ /// of outgoing edges of a node \c n
+ /// in graph \c G of type \c Graph as follows.
+ /// \code
+ ///int count=0;
+ ///for(Graph::InEdgeIt e(G,n);G.valid(e);G.next(e)) count++;
+ /// \endcode
+
+ class InEdgeIt : public Edge {
+ public:
+ /// @warning The default constructor sets the iterator
+ /// to an undefined value.
+ InEdgeIt() {}
+ /// Initialize the iterator to be invalid
+ InEdgeIt(Invalid) {}
+ InEdgeIt(const StaticGraphSkeleton &, Node) {}
+ };
+ // class SymEdgeIt : public Edge {};
+
+ /// This iterator goes through each edge.
+
+ /// This iterator goes through each edge of a graph.
+ /// Its usage is quite simple, for example you can count the number
+ /// of edges in a graph \c G of type \c Graph as follows:
+ /// \code
+ ///int count=0;
+ ///for(Graph::EdgeIt e(G);G.valid(e);G.next(e)) count++;
+ /// \endcode
+ class EdgeIt : public Edge {
+ public:
+ /// @warning The default constructor sets the iterator
+ /// to an undefined value.
+ EdgeIt() {}
+ /// Initialize the iterator to be invalid
+ EdgeIt(Invalid) {}
+ EdgeIt(const StaticGraphSkeleton &) {}
+ };
- class InEdgeIt : public Edge {
- public:
- /// @warning The default constructor sets the iterator
- /// to an undefined value.
- InEdgeIt() {}
- /// Initialize the iterator to be invalid
- InEdgeIt(Invalid) {}
- InEdgeIt(const GraphSkeleton &, Node) {}
- };
- // class SymEdgeIt : public Edge {};
+ /// First node of the graph.
- /// This iterator goes through each edge.
+ /// \retval i the first node.
+ /// \return the first node.
+ ///
+ NodeIt &first(NodeIt &i) const { return i;}
- /// This iterator goes through each edge of a graph.
- /// Its usage is quite simple, for example you can count the number
- /// of edges in a graph \c G of type \c Graph as follows:
- /// \code
- ///int count=0;
- ///for(Graph::EdgeIt e(G);G.valid(e);G.next(e)) count++;
- /// \endcode
- class EdgeIt : public Edge {
- public:
- /// @warning The default constructor sets the iterator
- /// to an undefined value.
- EdgeIt() {}
- /// Initialize the iterator to be invalid
- EdgeIt(Invalid) {}
- EdgeIt(const GraphSkeleton &) {}
- };
+ /// The first incoming edge.
+ InEdgeIt &first(InEdgeIt &i, Node) const { return i;}
+ /// The first outgoing edge.
+ OutEdgeIt &first(OutEdgeIt &i, Node) const { return i;}
+ // SymEdgeIt &first(SymEdgeIt &, Node) const { return i;}
+ /// The first edge of the Graph.
+ EdgeIt &first(EdgeIt &i) const { return i;}
+
+ // Node getNext(Node) const {}
+ // InEdgeIt getNext(InEdgeIt) const {}
+ // OutEdgeIt getNext(OutEdgeIt) const {}
+ // //SymEdgeIt getNext(SymEdgeIt) const {}
+ // EdgeIt getNext(EdgeIt) const {}
+
+ /// Go to the next node.
+ NodeIt &next(NodeIt &i) const { return i;}
+ /// Go to the next incoming edge.
+ InEdgeIt &next(InEdgeIt &i) const { return i;}
+ /// Go to the next outgoing edge.
+ OutEdgeIt &next(OutEdgeIt &i) const { return i;}
+ //SymEdgeIt &next(SymEdgeIt &) const {}
+ /// Go to the next edge.
+ EdgeIt &next(EdgeIt &i) const { return i;}
+
+ ///Gives back the head node of an edge.
+ Node head(Edge) const { return INVALID; }
+ ///Gives back the tail node of an edge.
+ Node tail(Edge) const { return INVALID; }
+
+ // Node aNode(InEdgeIt) const {}
+ // Node aNode(OutEdgeIt) const {}
+ // Node aNode(SymEdgeIt) const {}
- /// First node of the graph.
+ // Node bNode(InEdgeIt) const {}
+ // Node bNode(OutEdgeIt) const {}
+ // Node bNode(SymEdgeIt) const {}
- /// \retval i the first node.
- /// \return the first node.
- ///
- NodeIt &first(NodeIt &i) const { return i;}
+ /// Checks if a node iterator is valid
- /// The first incoming edge.
- InEdgeIt &first(InEdgeIt &i, Node) const { return i;}
- /// The first outgoing edge.
- OutEdgeIt &first(OutEdgeIt &i, Node) const { return i;}
- // SymEdgeIt &first(SymEdgeIt &, Node) const { return i;}
- /// The first edge of the Graph.
- EdgeIt &first(EdgeIt &i) const { return i;}
-
-// Node getNext(Node) const {}
-// InEdgeIt getNext(InEdgeIt) const {}
-// OutEdgeIt getNext(OutEdgeIt) const {}
-// //SymEdgeIt getNext(SymEdgeIt) const {}
-// EdgeIt getNext(EdgeIt) const {}
-
- /// Go to the next node.
- NodeIt &next(NodeIt &i) const { return i;}
- /// Go to the next incoming edge.
- InEdgeIt &next(InEdgeIt &i) const { return i;}
- /// Go to the next outgoing edge.
- OutEdgeIt &next(OutEdgeIt &i) const { return i;}
- //SymEdgeIt &next(SymEdgeIt &) const {}
- /// Go to the next edge.
- EdgeIt &next(EdgeIt &i) const { return i;}
-
- ///Gives back the head node of an edge.
- Node head(Edge) const { return INVALID; }
- ///Gives back the tail node of an edge.
- Node tail(Edge) const { return INVALID; }
-
- // Node aNode(InEdgeIt) const {}
- // Node aNode(OutEdgeIt) const {}
- // Node aNode(SymEdgeIt) const {}
+ ///\todo Maybe, it would be better if iterator converted to
+ ///bool directly, as Jacint prefers.
+ bool valid(const Node&) const { return true;}
+ /// Checks if an edge iterator is valid
- // Node bNode(InEdgeIt) const {}
- // Node bNode(OutEdgeIt) const {}
- // Node bNode(SymEdgeIt) const {}
+ ///\todo Maybe, it would be better if iterator converted to
+ ///bool directly, as Jacint prefers.
+ bool valid(const Edge&) const { return true;}
- /// Checks if a node iterator is valid
+ ///Gives back the \e id of a node.
- ///\todo Maybe, it would be better if iterator converted to
- ///bool directly, as Jacint prefers.
- bool valid(const Node&) const { return true;}
- /// Checks if an edge iterator is valid
+ ///\warning Not all graph structures provide this feature.
+ ///
+ int id(const Node&) const { return 0;}
+ ///Gives back the \e id of an edge.
- ///\todo Maybe, it would be better if iterator converted to
- ///bool directly, as Jacint prefers.
- bool valid(const Edge&) const { return true;}
+ ///\warning Not all graph structures provide this feature.
+ ///
+ int id(const Edge&) const { return 0;}
- ///Gives back the \e id of a node.
+ /// Resets the graph.
- ///\warning Not all graph structures provide this feature.
- ///
- int id(const Node&) const { return 0;}
- ///Gives back the \e id of an edge.
+ /// This function deletes all edges and nodes of the graph.
+ /// It also frees the memory allocated to store them.
+ void clear() {}
- ///\warning Not all graph structures provide this feature.
- ///
- int id(const Edge&) const { return 0;}
+ int nodeNum() const { return 0;}
+ int edgeNum() const { return 0;}
- //void setInvalid(Node &) const {};
- //void setInvalid(Edge &) const {};
-
- ///Add a new node to the graph.
- /// \return the new node.
- ///
- Node addNode() { return INVALID;}
- ///Add a new edge to the graph.
- ///Add a new edge to the graph with tail node \c tail
- ///and head node \c head.
- ///\return the new edge.
- Edge addEdge(Node, Node) { return INVALID;}
-
- /// Resets the graph.
+ ///Reference map of the nodes to type \c T.
- /// This function deletes all edges and nodes of the graph.
- /// It also frees the memory allocated to store them.
- void clear() {}
-
- int nodeNum() const { return 0;}
- int edgeNum() const { return 0;}
-
- ///Read/write/reference map of the nodes to type \c T.
-
- ///Read/write/reference map of the nodes to type \c T.
- /// \sa MemoryMapSkeleton
- /// \todo We may need copy constructor
- /// \todo We may need conversion from other nodetype
- /// \todo We may need operator=
- /// \warning Making maps that can handle bool type (NodeMap<bool>)
- /// needs extra attention!
+ ///Reference map of the nodes to type \c T.
+ /// \sa ReferenceSkeleton
+ /// \warning Making maps that can handle bool type (NodeMap<bool>)
+ /// needs extra attention!
- template<class T> class NodeMap
- {
- public:
- typedef T ValueType;
- typedef Node KeyType;
+ template<class T> class NodeMap
+ : public ReferenceMap< Node, T >
+ {
+ public:
- NodeMap(const GraphSkeleton &) {}
- NodeMap(const GraphSkeleton &, T) {}
+ class ReferenceMap<Node,T>;
- template<typename TT> NodeMap(const NodeMap<TT> &) {}
+ NodeMap(const StaticGraphSkeleton &) {}
+ NodeMap(const StaticGraphSkeleton &, T) {}
- /// Sets the value of a node.
+ ///Copy constructor
+ template<typename TT> NodeMap(const NodeMap<TT> &) {}
+ ///Assignment operator
+ template<typename TT> NodeMap &operator=(const NodeMap<TT> &)
+ {return *this;}
+ };
- /// Sets the value associated with node \c i to the value \c t.
- ///
- void set(Node, T) {}
- // Gets the value of a node.
- //T get(Node i) const {return *(T*)0;} //FIXME: Is it necessary?
- T &operator[](Node) {return *(T*)0;}
- const T &operator[](Node) const {return *(T*)0;}
+ ///Reference map of the edges to type \c T.
- /// Updates the map if the graph has been changed
+ ///Reference map of the edges to type \c T.
+ /// \sa ReferenceSkeleton
+ /// \warning Making maps that can handle bool type (EdgeMap<bool>)
+ /// needs extra attention!
+ template<class T> class EdgeMap
+ : public ReferenceMap<Edge,T>
+ {
+ public:
+ typedef T ValueType;
+ typedef Edge KeyType;
- /// \todo Do we need this?
- ///
- void update() {}
- void update(T a) {} //FIXME: Is it necessary
+ EdgeMap(const StaticGraphSkeleton &) {}
+ EdgeMap(const StaticGraphSkeleton &, T ) {}
+
+ ///Copy constructor
+ template<typename TT> EdgeMap(const EdgeMap<TT> &) {}
+ ///Assignment operator
+ template<typename TT> EdgeMap &operator=(const EdgeMap<TT> &)
+ {return *this;}
+ };
};
- ///Read/write/reference map of the edges to type \c T.
- ///Read/write/reference map of the edges to type \c T.
- ///It behaves exactly in the same way as \ref NodeMap.
- /// \sa NodeMap
- /// \sa MemoryMapSkeleton
- /// \todo We may need copy constructor
- /// \todo We may need conversion from other edgetype
- /// \todo We may need operator=
- template<class T> class EdgeMap
+
+ /// An empty graph class.
+
+ /// This class provides everything that \c StaticGraphSkeleton
+ /// with additional functionality which enables to build a
+ /// graph from scratch.
+ class GraphSkeleton : public StaticGraphSkeleton
{
public:
- typedef T ValueType;
- typedef Edge KeyType;
+ /// Defalult constructor.
+ GraphSkeleton() {}
+ ///Copy consructor.
- EdgeMap(const GraphSkeleton &) {}
- EdgeMap(const GraphSkeleton &, T ) {}
-
- ///\todo It can copy between different types.
+ ///\todo It is not clear, what we expect from a copy constructor.
+ ///E.g. How to assign the nodes/edges to each other? What about maps?
+ GraphSkeleton(const GraphSkeleton &G) {}
+
+ ///Add a new node to the graph.
+
+ /// \return the new node.
///
- template<typename TT> EdgeMap(const EdgeMap<TT> &) {}
+ Node addNode() { return INVALID;}
+ ///Add a new edge to the graph.
- void set(Edge, T) {}
- //T get(Edge) const {return *(T*)0;}
- T &operator[](Edge) {return *(T*)0;}
- const T &operator[](Edge) const {return *(T*)0;}
+ ///Add a new edge to the graph with tail node \c tail
+ ///and head node \c head.
+ ///\return the new edge.
+ Edge addEdge(Node, Node) { return INVALID;}
- void update() {}
- void update(T a) {} //FIXME: Is it necessary
+ /// Resets the graph.
+
+ /// This function deletes all edges and nodes of the graph.
+ /// It also frees the memory allocated to store them.
+ /// \todo It might belong to \c EraseableGraphSkeleton.
+ void clear() {}
};
- };
- /// An empty eraseable graph class.
+ /// An empty eraseable graph class.
- /// This class provides all the common features of an \e eraseable graph
- /// structure,
- /// however completely without implementations and real data structures
- /// behind the interface.
- /// All graph algorithms should compile with this class, but it will not
- /// run properly, of course.
- ///
- /// \todo This blabla could be replaced by a sepatate description about
- /// Skeletons.
- ///
- /// It can be used for checking the interface compatibility,
- /// or it can serve as a skeleton of a new graph structure.
- ///
- /// Also, you will find here the full documentation of a certain graph
- /// feature, the documentation of a real graph imlementation
- /// like @ref ListGraph or
- /// @ref SmartGraph will just refer to this structure.
- class EraseableGraphSkeleton : public GraphSkeleton
- {
- public:
- /// Deletes a node.
- void erase(Node n) {}
- /// Deletes an edge.
- void erase(Edge e) {}
-
- /// Defalult constructor.
- EraseableGraphSkeleton() {}
- ///Copy consructor.
- EraseableGraphSkeleton(const GraphSkeleton &G) {}
- };
+ /// This class is an extension of \c GraphSkeleton. It also makes it
+ /// possible to erase edges or nodes.
+ class EraseableGraphSkeleton : public GraphSkeleton
+ {
+ public:
+ /// Deletes a node.
+ void erase(Node n) {}
+ /// Deletes an edge.
+ void erase(Edge e) {}
+
+ /// Defalult constructor.
+ EraseableGraphSkeleton() {}
+ ///Copy consructor.
+ EraseableGraphSkeleton(const GraphSkeleton &G) {}
+ };
+ // @}
+ } //namespace skeleton
- // @}
-
} //namespace hugo
Modified: hugo/trunk/src/hugo/skeletons/maps.h
==============================================================================
--- hugo/trunk/src/hugo/skeletons/maps.h (original)
+++ hugo/trunk/src/hugo/skeletons/maps.h Thu Jul 22 21:59:18 2004
@@ -12,7 +12,7 @@
/// Readable map concept
template<typename K, typename T>
- class ReadableMap
+ class ReadMap
{
public:
/// Map's key type.
@@ -23,18 +23,14 @@
/// Returns the value associated with a key.
ValueType operator[](const KeyType &k) const {return ValueType();}
- /// Copy contsructor. (optional)
- ReadableMap(const ReadableMap&) {}
- /// Assignment operator. (optional)
- ReadableMap& operator=(const ReadableMap&) {return *this;}
-
- ReadableMap() {}
+ ///Default constructor
+ ReadMap() {}
};
/// Writable map concept
template<typename K, typename T>
- class WritableMap
+ class WriteMap
{
public:
/// Map's key type.
@@ -45,13 +41,14 @@
/// Sets the value associated with a key.
void set(const KeyType &k,const ValueType &t) {}
- WritableMap() {}
+ ///Default constructor
+ WriteMap() {}
};
///Read/Writeable map concept
template<typename K, typename T>
- class ReadWritableMap : public ReadableMap<K,T>,
- public WritableMap<K,T>
+ class ReadWriteMap : public ReadMap<K,T>,
+ public WriteMap<K,T>
{
public:
/// Map's key type.
@@ -64,67 +61,39 @@
/// Sets the value associated with a key.
void set(const KeyType &k,const ValueType &t) {}
- /// Copy contsructor. (optional)
- ReadWritableMap(const ReadWritableMap&) {}
- /// Assignment operator. (optional)
- ReadWritableMap& operator=(const ReadWritableMap&) {return *this;}
-
- /// Facility to define a map with an other value type (optional)
- template<typename T1>
- struct rebind {
- /// The type of a map with the given value type
- typedef ReadWritableMap<K,T1> other;
- };
- /// @brief Constructor that copies all keys from the other map and
- /// assigns to them a default value (optional)
- template<typename T1>
- ReadWritableMap(const ReadWritableMap<K,T1> &map, const ValueType &v) {}
-
- ReadWritableMap() {}
+ ///Default constructor
+ ReadWriteMap() {}
};
///Dereferable map concept
template<typename K, typename T>
- class DereferableMap : public ReadWritableMap<K,T>
+ class ReferenceMap : public ReadWriteMap<K,T>
{
public:
/// Map's key type.
typedef K KeyType;
/// Map's value type. (The type of objects associated with the keys).
typedef T ValueType;
- /// Map's reference type. (Reference to an object associated with a key)
+
+ protected:
+ ValueType tmp;
+ public:
typedef ValueType& ReferenceType;
/// Map's const reference type.
typedef const ValueType& ConstReferenceType;
///Returns a reference to the value associated to a key.
- ReferenceType operator[](const KeyType &i);
+ ReferenceType operator[](const KeyType &i) { return tmp; }
///Returns a const reference to the value associated to a key.
- ConstReferenceType operator[](const KeyType &i) const;
+ ConstReferenceType operator[](const KeyType &i) const
+ { return tmp; }
/// Sets the value associated with a key.
void set(const KeyType &k,const ValueType &t) { operator[](k)=t; }
- /// Copy contsructor. (optional)
- DereferableMap(const DereferableMap&) {}
- /// Assignment operator. (optional)
- DereferableMap& operator=(const DereferableMap&) {return *this;}
-
- /// Facility to define a map with an other value type (optional)
- template<typename T1>
- struct rebind {
- /// The type of a map with the given value type
- typedef DereferableMap<K,T1> other;
- };
- /// @brief Constructor that copies all keys from the other map and
- /// assigns to them a default value (optional)
- template<typename T1>
- DereferableMap(const DereferableMap<K,T1> &map, const ValueType &v) {}
-
- DereferableMap() {}
+ ///Default constructor
+ ReferenceMap() {}
};
-
-
- }
-}
+ } //namespace skeleton
+} //namespace hugo
#endif // HUGO_MAPSKELETON_H
More information about the Lemon-commits
mailing list