$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
From: asutton_at_[hidden]
Date: 2008-05-30 08:06:03
Author: asutton
Date: 2008-05-30 08:06:02 EDT (Fri, 30 May 2008)
New Revision: 45937
URL: http://svn.boost.org/trac/boost/changeset/45937
Log:
Fixed all of the iterators to actually work as iterators.
Text files modified: 
   sandbox/SOC/2008/graphs/boost/graphs/adjacency_list/vs/indexed_vertex_iterator.hpp |   188 ++++++++++++++++++++++++++------------- 
   sandbox/SOC/2008/graphs/boost/graphs/adjacency_list/vs/mapped_vertex_iterator.hpp  |    98 +++++++++++++++-----                    
   sandbox/SOC/2008/graphs/boost/graphs/adjacency_list/vs/value_vertex_iterator.hpp   |   110 +++++++++++++++-------                  
   3 files changed, 272 insertions(+), 124 deletions(-)
Modified: sandbox/SOC/2008/graphs/boost/graphs/adjacency_list/vs/indexed_vertex_iterator.hpp
==============================================================================
--- sandbox/SOC/2008/graphs/boost/graphs/adjacency_list/vs/indexed_vertex_iterator.hpp	(original)
+++ sandbox/SOC/2008/graphs/boost/graphs/adjacency_list/vs/indexed_vertex_iterator.hpp	2008-05-30 08:06:02 EDT (Fri, 30 May 2008)
@@ -10,7 +10,9 @@
 
 /**
  * The indexed vertex iterator provides a vertex iterator for stores whose
- * descriptors cannot be pointers (i.e., vectors).
+ * descriptors cannot be pointers (i.e., vectors). By virtue of the fact that
+ * Store is required to be a vector of something, this is a random access
+ * iterator.
  */
 template <typename Store>
 class indexed_vertex_iterator
@@ -26,76 +28,134 @@
     typedef vertex_descriptor reference;
     typedef vertex_descriptor pointer;
 
-    inline indexed_vertex_iterator()
-        : store(0)
-        , iter()
-    { }
-
-    inline indexed_vertex_iterator(indexed_vertex_iterator const& x)
-        : store(x.store)
-        , iter(x.iter)
-    { }
-
-    inline indexed_vertex_iterator(Store const& s, iterator const& x)
-        : store(&s)
-        , iter(x)
-    { }
-
-    inline indexed_vertex_iterator& operator++()
-    {
-        ++iter;
-        return *this;
-    }
-
-    inline indexed_vertex_iterator& operator=(indexed_vertex_iterator const& x)
-    {
-        indexed_vertex_iterator t(x);
-        swap(t);
-        return *this;
-    }
-
-    inline indexed_vertex_iterator& operator+=(difference_type n)
-    {
-        iter += n;
-        return *this;
-    }
-
-    inline indexed_vertex_iterator& operator-=(difference_type n)
-    {
-        iter -= n;
-        return *this;
-    }
-
-    // Support addition and subtraction as per random access iterators
-    inline indexed_vertex_iterator operator+(difference_type n) const
-    { return iter + n; }
+    // Constructors
+    inline indexed_vertex_iterator();
+    inline indexed_vertex_iterator(indexed_vertex_iterator const& x);
+    inline indexed_vertex_iterator(Store const& s, iterator const& x);
+
+    // Assignment and increment
+    inline indexed_vertex_iterator& operator=(indexed_vertex_iterator const& x);
+    inline indexed_vertex_iterator& operator+=(difference_type n);
+    inline indexed_vertex_iterator& operator-=(difference_type n);
+    inline indexed_vertex_iterator& operator++();
+    inline indexed_vertex_iterator& operator--();
+
+    inline indexed_vertex_iterator operator+(difference_type n) const;
+    inline indexed_vertex_iterator operator-(difference_type n) const;
+    inline difference_type operator-(indexed_vertex_iterator const& x) const;
 
-    inline indexed_vertex_iterator operator-(difference_type n) const
-    { return iter - n; }
+    inline reference operator*();
 
-    inline difference_type operator-(indexed_vertex_iterator const& x) const
-    { return iter - x.iter; }
+    inline bool operator==(indexed_vertex_iterator const& x) const;
+    inline bool operator!=(indexed_vertex_iterator const& x) const;
 
-    // The returned descriptor is simply the distance from the beginning of
-    // the underlying store to the end.
-    inline reference operator*()
-    { return std::distance(store->begin(), iter); }
+private:
+    Store const* store;
+    iterator iter;
+};
 
-    inline bool operator==(indexed_vertex_iterator const& x) const
-    { return (store == x.store) && (iter == x.iter); }
+template <typename S>
+indexed_vertex_iterator<S>::indexed_vertex_iterator()
+    : store(0)
+    , iter()
+{ }
+
+template <typename S>
+indexed_vertex_iterator<S>::indexed_vertex_iterator(indexed_vertex_iterator const& x)
+    : store(x.store)
+    , iter(x.iter)
+{ }
+
+template <typename S>
+indexed_vertex_iterator<S>::indexed_vertex_iterator(S const& s, iterator const& x)
+    : store(&s)
+    , iter(x)
+{ }
+
+template <typename S>
+indexed_vertex_iterator<S>&
+indexed_vertex_iterator<S>::operator=(indexed_vertex_iterator const& x)
+{
+    iter = x.iter;
+    store = x.store;
+    return *this;
+}
+
+template <typename S>
+indexed_vertex_iterator<S>&
+indexed_vertex_iterator<S>::operator+=(difference_type n)
+{
+    iter += n;
+    return *this;
+}
+
+template <typename S>
+indexed_vertex_iterator<S>&
+indexed_vertex_iterator<S>::operator-=(difference_type n)
+{
+    iter -= n;
+    return *this;
+}
+
+template <typename S>
+indexed_vertex_iterator<S>&
+indexed_vertex_iterator<S>::operator++()
+{
+    ++iter;
+    return *this;
+}
+
+template <typename S>
+indexed_vertex_iterator<S>&
+indexed_vertex_iterator<S>::operator--()
+{
+    --iter;
+    return *this;
+}
+
+template <typename S>
+indexed_vertex_iterator<S>
+indexed_vertex_iterator<S>::operator+(difference_type n) const
+{
+    return iter + n;
+}
 
-    inline bool operator!=(indexed_vertex_iterator const& x) const
-    { return (store == x.store) && (iter != x.iter); }
+template <typename S>
+indexed_vertex_iterator<S>
+indexed_vertex_iterator<S>::operator-(difference_type n) const
+{
+    return iter - n;
+}
 
-    inline void swap(indexed_vertex_iterator& x)
-    {
-        std::swap(store, x.store);
-        std::swap(iter, x.iter);
-    }
+template <typename S>
+typename indexed_vertex_iterator<S>::difference_type
+indexed_vertex_iterator<S>::operator-(indexed_vertex_iterator const& x) const
+{
+    return iter - x.iter;
+}
 
-    Store const* store;
-    iterator iter;
-};
+template <typename S>
+typename indexed_vertex_iterator<S>::reference
+indexed_vertex_iterator<S>::operator*()
+{
+    // The returned descriptor is simply the distance from the beginning of
+    // the underlying store to the end.
+    return std::distance(store->begin(), iter);
+}
+
+template <typename S>
+bool
+indexed_vertex_iterator<S>::operator==(indexed_vertex_iterator const& x) const
+{
+     return (store == x.store) && (iter == x.iter);
+}
+
+template <typename S>
+bool
+indexed_vertex_iterator<S>::operator!=(indexed_vertex_iterator const& x) const
+{
+    return (store == x.store) && (iter != x.iter);
+}
 
 } /* namespace adj_list */
 } /* namespace graphs */
Modified: sandbox/SOC/2008/graphs/boost/graphs/adjacency_list/vs/mapped_vertex_iterator.hpp
==============================================================================
--- sandbox/SOC/2008/graphs/boost/graphs/adjacency_list/vs/mapped_vertex_iterator.hpp	(original)
+++ sandbox/SOC/2008/graphs/boost/graphs/adjacency_list/vs/mapped_vertex_iterator.hpp	2008-05-30 08:06:02 EDT (Fri, 30 May 2008)
@@ -9,7 +9,8 @@
 /**
  * The mapped vertex iterator provides a vertex iterator pair associative
  * storage containers. This essintially wraps a store iterator, providing
- * the ability to dererence to descriptors.
+ * the ability to dererence to descriptors. Because this iterator is taken
+ * from pair associative structures, it is bidirectional but not random access.
  */
 template <typename Store>
 class mapped_vertex_iterator
@@ -19,40 +20,89 @@
     typedef typename Store::mapped_type vertex_type;
     typedef typename vertex_type::descriptor_type vertex_descriptor;
 
+    typedef typename iterator::iterator_category iterator_category;
+    typedef typename iterator::difference_type difference_type;
     typedef vertex_descriptor value_type;
     typedef vertex_descriptor reference;
     typedef vertex_descriptor pointer;
 
-    inline mapped_vertex_iterator()
-        : iter()
-    { }
-
-    inline mapped_vertex_iterator(mapped_vertex_iterator const& x)
-        : iter(x.iter)
-    { }
-
-    inline mapped_vertex_iterator(iterator const& x)
-        : iter(x)
-    { }
-
-    inline mapped_vertex_iterator& operator++()
-    {
-        ++iter;
-        return *this;
-    }
+    inline mapped_vertex_iterator();
+    inline mapped_vertex_iterator(mapped_vertex_iterator const& x);
+    inline mapped_vertex_iterator(iterator const& x);
 
-    inline reference operator*()
-    { return &const_cast<vertex_type&>(iter->second); }
+    inline mapped_vertex_iterator& operator=(mapped_vertex_iterator const& x);
+    inline mapped_vertex_iterator& operator++();
+    inline mapped_vertex_iterator& operator--();
 
-    inline bool operator==(mapped_vertex_iterator const& x) const
-    { return iter == x.iter; }
+    inline reference operator*();
 
-    inline bool operator!=(mapped_vertex_iterator const& x) const
-    { return iter != x.iter; }
+    inline bool operator==(mapped_vertex_iterator const& x) const;
+    inline bool operator!=(mapped_vertex_iterator const& x) const;
 
+private:
     iterator iter;
 };
 
+template <typename S>
+mapped_vertex_iterator<S>::mapped_vertex_iterator()
+    : iter()
+{ }
+
+template <typename S>
+mapped_vertex_iterator<S>::mapped_vertex_iterator(mapped_vertex_iterator const& x)
+    : iter(x.iter)
+{ }
+
+template <typename S>
+mapped_vertex_iterator<S>::mapped_vertex_iterator(iterator const& x)
+    : iter(x)
+{ }
+
+template <typename S>
+mapped_vertex_iterator<S>&
+mapped_vertex_iterator<S>::operator=(mapped_vertex_iterator const& x)
+{
+    iter = x.iter;
+    return *this;
+}
+
+template <typename S>
+mapped_vertex_iterator<S>&
+mapped_vertex_iterator<S>::operator++()
+{
+    ++iter;
+    return *this;
+}
+
+template <typename S>
+mapped_vertex_iterator<S>&
+mapped_vertex_iterator<S>::operator--()
+{
+    --iter;
+    return *this;
+}
+
+template <typename S>
+typename mapped_vertex_iterator<S>::reference
+mapped_vertex_iterator<S>::operator*()
+{
+    return &const_cast<vertex_type&>(iter->second);
+}
+
+template <typename S>
+bool
+mapped_vertex_iterator<S>::operator==(mapped_vertex_iterator const& x) const
+{
+    return iter == x.iter;
+}
+
+template <typename S>
+bool
+mapped_vertex_iterator<S>::operator!=(mapped_vertex_iterator const& x) const
+{
+    return iter != x.iter;
+}
+
 } /* namespace adj_list */
 } /* namespace graph */
 } /* namespace boost */
Modified: sandbox/SOC/2008/graphs/boost/graphs/adjacency_list/vs/value_vertex_iterator.hpp
==============================================================================
--- sandbox/SOC/2008/graphs/boost/graphs/adjacency_list/vs/value_vertex_iterator.hpp	(original)
+++ sandbox/SOC/2008/graphs/boost/graphs/adjacency_list/vs/value_vertex_iterator.hpp	2008-05-30 08:06:02 EDT (Fri, 30 May 2008)
@@ -1,6 +1,6 @@
 
-#ifndef BOOST_GRAPHS_ADJACENCY_LIST_VALUE_VERTEX_ITERATOR_HPP
-#define BOOST_GRAPHS_ADJACENCY_LIST_VALUE_VERTEX_ITERATOR_HPP
+#ifndef BOOST_GRAPHS_ADJACENCY_LIST_SIMPLE_VERTEX_ITERATOR_HPP
+#define BOOST_GRAPHS_ADJACENCY_LIST_SIMPLE_VERTEX_ITERATOR_HPP
 
 #include <iterator>
 
@@ -12,12 +12,9 @@
  * The value vertex iterator provides a vertex iterator unique associative
  * containers and sequences that don't invalidate memory on insertions
  * (lists).
- *
- * Note that this is actually a random access iterator and can be used to
- * support trivial fill (memset) and copy (memcpy) operations.
  */
 template <typename Store>
-class value_vertex_iterator
+class simple_vertex_iterator
 {
     typedef typename Store::const_iterator iterator;
 public:
@@ -25,47 +22,88 @@
     typedef typename vertex_type::descriptor_type vertex_descriptor;
 
     typedef typename iterator::iterator_category iterator_category;
+    typedef typename iterator::difference_type difference_type;
     typedef vertex_descriptor value_type;
     typedef vertex_descriptor reference;
     typedef vertex_descriptor pointer;
-    typedef typename iterator::difference_type difference_type;
 
-    inline value_vertex_iterator()
-        : iter()
-    { }
-
-    inline value_vertex_iterator(value_vertex_iterator const& x)
-        : iter(x.iter)
-    { }
-
-    inline value_vertex_iterator(iterator const& x)
-        : iter(x)
-    { }
-
-    inline value_vertex_iterator& operator++()
-    {
-        ++iter;
-        return *this;
-    }
-
-    inline value_vertex_iterator& operator--()
-    {
-        --iter;
-        return *this;
-    }
+    inline simple_vertex_iterator();
+    inline simple_vertex_iterator(simple_vertex_iterator const& x);
+    inline simple_vertex_iterator(iterator const& x);
 
-    inline reference operator*()
-    { return &const_cast<vertex_type&>(*iter); }
+    inline simple_vertex_iterator& operator=(simple_vertex_iterator const& x);
+    inline simple_vertex_iterator& operator++();
+    inline simple_vertex_iterator& operator--();
 
-    inline bool operator==(value_vertex_iterator const& x) const
-    { return iter == x.iter; }
+    inline reference operator*();
 
-    inline bool operator!=(value_vertex_iterator const& x) const
-    { return iter != x.iter; }
+    inline bool operator==(simple_vertex_iterator const& x) const;
+    inline bool operator!=(simple_vertex_iterator const& x) const;
 
+private:
     iterator iter;
 };
 
+template <typename S>
+simple_vertex_iterator<S>::simple_vertex_iterator()
+    : iter()
+{ }
+
+template <typename S>
+simple_vertex_iterator<S>::simple_vertex_iterator(simple_vertex_iterator const& x)
+    : iter(x.iter)
+{ }
+
+template <typename S>
+simple_vertex_iterator<S>::simple_vertex_iterator(iterator const& x)
+    : iter(x)
+{ }
+
+template <typename S>
+simple_vertex_iterator<S>&
+simple_vertex_iterator<S>::operator=(simple_vertex_iterator const& x)
+{
+    iter = x.iter;
+    return *this;
+}
+
+template <typename S>
+simple_vertex_iterator<S>&
+simple_vertex_iterator<S>::operator++()
+{
+    ++iter;
+    return *this;
+}
+
+template <typename S>
+simple_vertex_iterator<S>&
+simple_vertex_iterator<S>::operator--()
+{
+    --iter;
+    return *this;
+}
+
+template <typename S>
+typename simple_vertex_iterator<S>::reference
+simple_vertex_iterator<S>::operator*()
+{
+    return &const_cast<vertex_type&>(*iter);
+}
+
+template <typename S>
+bool
+simple_vertex_iterator<S>::operator==(simple_vertex_iterator const& x) const
+{
+    return iter == x.iter;
+}
+
+template <typename S>
+bool
+simple_vertex_iterator<S>::operator!=(simple_vertex_iterator const& x) const
+{
+    return iter != x.iter;
+}
+
 } /* namespace adj_list */
 } /* namespace graphs */
 } /* namespace boost */