Boost logo

Boost-Commit :

From: asutton_at_[hidden]
Date: 2008-06-16 09:16:48


Author: asutton
Date: 2008-06-16 09:16:47 EDT (Mon, 16 Jun 2008)
New Revision: 46419
URL: http://svn.boost.org/trac/boost/changeset/46419

Log:
Added missing file.
Fixed the iterator type to remove consts on descriptors (as a fix for the
edge set).

Added:
   sandbox/SOC/2008/graphs/branches/iu/boost/graphs/incidence_iterator.hpp (contents, props changed)

Added: sandbox/SOC/2008/graphs/branches/iu/boost/graphs/incidence_iterator.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/graphs/branches/iu/boost/graphs/incidence_iterator.hpp 2008-06-16 09:16:47 EDT (Mon, 16 Jun 2008)
@@ -0,0 +1,72 @@
+
+#ifndef INCIDENCE_ITERATOR_HPP
+#define INCIDENCE_ITERATOR_HPP
+
+#include <boost/type_traits.hpp>
+
+#include "edge.hpp"
+
+/**
+ * The incidence iterator is an abstraction over the incidence iterators of
+ * a vertice's incidence store. Specifically when dereferenced, these iterators
+ * will result in edge descriptors.
+ */
+template <typename Iter>
+class incidence_iterator
+{
+ typedef Iter base_iterator;
+ typedef typename base_iterator::value_type base_value_type;
+ typedef typename base_value_type::first_type vertex_descriptor;
+ typedef typename base_value_type::second_type property_descriptor;
+public:
+ // This is a little misleading. This iterator can be either bidi or random.
+ // Clearly, we're going to be constraining members using some concept stuff
+ // when it becomes available.
+ typedef typename base_iterator::iterator_category iterator_category;
+
+ // Because incidence sets are built on maps, the key type of an incidence
+ // iterator is given as const key - which causes edges to be instantiated
+ // over constant descriptors (which, perhaps, they should be). For now,
+ // just remove the const and get on with things.
+ typedef undirected_edge<
+ typename boost::remove_const<vertex_descriptor>::type,
+ property_descriptor
+ > value_type;
+ typedef value_type reference;
+ typedef value_type pointer;
+
+ inline incidence_iterator()
+ : _base(), _iter()
+ { }
+
+ inline incidence_iterator(incidence_iterator const& x)
+ : _base(x._base), _iter(x._iter)
+ { }
+
+ inline incidence_iterator(vertex_descriptor v, base_iterator const& x)
+ : _base(v), _iter(x)
+ { }
+
+ inline incidence_iterator& operator++()
+ { ++_iter; return *this; }
+
+ inline incidence_iterator& operator--()
+ { --_iter; return *this; }
+
+ // Iterators are equivalent if they reference the same edge.
+ inline bool operator==(incidence_iterator const& x)
+ { return **this == *x; }
+
+ inline bool operator!=(incidence_iterator const& x)
+ { return !this->operator==(x); }
+
+ inline reference operator*() const
+ { return reference(_base, _iter->first, _iter->second); }
+
+private:
+ vertex_descriptor _base;
+ base_iterator _iter;
+};
+
+
+#endif


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