|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r49796 - in sandbox/SOC/2008/graphs/trunk/libs/graphs: include/boost/graphs/adjacency_list test
From: asutton_at_[hidden]
Date: 2008-11-16 11:28:59
Author: asutton
Date: 2008-11-16 11:28:59 EST (Sun, 16 Nov 2008)
New Revision: 49796
URL: http://svn.boost.org/trac/boost/changeset/49796
Log:
Started work on migrating the vertex map.
Text files modified:
sandbox/SOC/2008/graphs/trunk/libs/graphs/include/boost/graphs/adjacency_list/vertex_map.hpp | 120 +---------------------------------------
sandbox/SOC/2008/graphs/trunk/libs/graphs/test/vertex_store.cpp | 2
2 files changed, 5 insertions(+), 117 deletions(-)
Modified: sandbox/SOC/2008/graphs/trunk/libs/graphs/include/boost/graphs/adjacency_list/vertex_map.hpp
==============================================================================
--- sandbox/SOC/2008/graphs/trunk/libs/graphs/include/boost/graphs/adjacency_list/vertex_map.hpp (original)
+++ sandbox/SOC/2008/graphs/trunk/libs/graphs/include/boost/graphs/adjacency_list/vertex_map.hpp 2008-11-16 11:28:59 EST (Sun, 16 Nov 2008)
@@ -13,18 +13,6 @@
template <typename, typename, typename, typename> class vertices_map;
/**
- * This metafunction defines the implementation requirements of a mapping of
- * vertices to the keys that describe them. This is function takes three
- * parameters: the type of key, a comparator template, and vertex allocator.
- *
- * The Compare parameter must be a unary template class rather than a fully
- * instantiated type. This makes it easier to pass arbitrary template functions
- * (e.g., less and greater) instead of instantiated types.
- *
- * The Alloc parameter is also a unary template class. In this case, the caller
- * does not know the final type of the allocator object. It us ultimately
- * instantiated as an allocator of key/vertex pairs.
- *
* @param Key The key type of the vertex map can be any LessThanComparable type.
* @param Compare A unary template class that implements a comparison of keys.
* @param Alloc An allocator for key/value pairs of the underliyng map.
@@ -37,8 +25,9 @@
{
typedef Key key_type;
- typedef std::map<Key, int, Compare<Key>, Alloc<std::pair<Key, int>>> dummy;
- typedef typename descriptor_traits<dummy>::descriptor_type vertex_descriptor;
+ typedef typename descriptor_traits<
+ std::map<Key, int, Compare<Key>, Alloc<std::pair<Key, int>>>
+ >::descriptor_type vertex_descriptor;
template <typename Vertex>
struct store
@@ -49,109 +38,6 @@
};
};
-/**
- * Implementation of the vertex set. This requires that vertices (actually
- * their label) are less-than comparable.
- *
- * @param Vertex The vertex type stored by the class.
- * @param Key The type of key mapping to vertices.
- * @param Compare An ordering over keys.
- * @param Alloc The allocator for Key/Vertex pairs.
- */
-template <typename Vertex, typename Key, typename Compare, typename Allocator>
-class vertices_map
-{
-public:
- typedef std::map<Key, Vertex, Compare, Allocator> store_type;
- typedef typename store_type::size_type size_type;
- typedef typename store_type::iterator iterator;
- typedef typename store_type::const_iterator const_iterator;
-
- typedef Key key_type;
-
- typedef Vertex vertex_type;
- typedef typename Vertex::vertex_label vertex_label;
-
- typedef typename descriptor_traits<store_type>::descriptor_type vertex_descriptor;
-
- typedef basic_vertex_iterator<store_type> vertex_iterator;
- typedef std::pair<vertex_iterator, vertex_iterator> vertex_range;
-
- inline vertices_map()
- : _verts()
- { }
-
- /**
- * Add a vertex to the store mapped to the given key, and having the given
- * label.
- */
- inline vertex_descriptor add(key_type const& k, vertex_label const& vp)
- { return make_descriptor(_verts, _verts.insert(std::make_pair(k, vp)).first); }
-
- /**
- * Find the vertex mapped to the given key and return a descriptor to it.
- */
- inline vertex_descriptor find(key_type const& k) const
- { return make_descriptor(_verts, _verts.find(k)); }
-
- /** @name Remove Vertex
- * Remove the vertex identified by the descriptor or the its label.
- */
- //@{
- inline void remove(vertex_descriptor d)
- { _verts.erase(make_iterator(_verts, d)); }
-
- inline void remove(key_type const& k)
- { _verts.erase(_verts.find(k)); }
- //@}
-
- /** Return the number of vertices in the map. */
- inline size_type size() const
- { return _verts.size(); }
-
- /** @name Vertex Iteration */
- //@{
- inline vertex_iterator begin_vertices() const
- { return vertex_iterator(_verts, _verts.begin()); }
-
- inline vertex_iterator end_vertices() const
- { return vertex_iterator(_verts, _verts.end()); }
-
- vertex_range vertices() const
- { return std::make_pair(begin_vertices(), end_vertices()); }
-
- inline iterator begin() const
- { return _verts.begin(); }
-
- inline iterator end() const
- { return _verts.end(); }
- //@}
-
- /** @name Vertex and Key Accessors */
- //@{
- vertex_type& vertex(vertex_descriptor v)
- { return make_iterator(_verts, v)->second; }
-
- vertex_type const& vertex(vertex_descriptor v) const
- { return make_iterator(_verts, v)->second; }
-
- key_type const& key(vertex_descriptor d) const
- { return make_iterator(_verts, d)->first; }
- //@}
-
- /** @name Property Accessors */
- //@{
- vertex_label& label(vertex_descriptor v)
- { return vertex(v).label(); }
-
- vertex_label const& label(vertex_descriptor v) const
- { return vertex(v).label(); }
- //@}
-
-private:
- mutable store_type _verts;
-};
-
} } } /* namespace boost::graphs::adjacency_list */
#endif
Modified: sandbox/SOC/2008/graphs/trunk/libs/graphs/test/vertex_store.cpp
==============================================================================
--- sandbox/SOC/2008/graphs/trunk/libs/graphs/test/vertex_store.cpp (original)
+++ sandbox/SOC/2008/graphs/trunk/libs/graphs/test/vertex_store.cpp 2008-11-16 11:28:59 EST (Sun, 16 Nov 2008)
@@ -6,6 +6,7 @@
#include <boost/graphs/adjacency_list/vertex_vector.hpp>
#include <boost/graphs/adjacency_list/vertex_list.hpp>
#include <boost/graphs/adjacency_list/vertex_set.hpp>
+#include <boost/graphs/adjacency_list/vertex_map.hpp>
using namespace std;
using namespace boost;
@@ -48,6 +49,7 @@
typedef vertex_vector<>::vertex_store<my_vertex>::type VV;
typedef vertex_list<>::vertex_store<my_vertex>::type VL;
typedef vertex_set<>::vertex_store<my_vertex>::type VS;
+ // typedef vertex_map<>::vertex_map<string, my_vertex>::type VM;
test<VV>();
test<VL>();
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk