Chris@16: //======================================================================= Chris@16: // Copyright 2002 Indiana University. Chris@16: // Copyright 2009 Trustees of Indiana University. Chris@16: // Authors: Andrew Lumsdaine, Lie-Quan Lee, Jeremy G. Siek, Michael Hansen Chris@16: // Chris@16: // Distributed under the Boost Software License, Version 1.0. (See Chris@16: // accompanying file LICENSE_1_0.txt or copy at Chris@16: // http://www.boost.org/LICENSE_1_0.txt) Chris@16: //======================================================================= Chris@16: Chris@16: #ifndef BOOST_GRAPH_DETAIL_INCREMENTAL_COMPONENTS_HPP Chris@16: #define BOOST_GRAPH_DETAIL_INCREMENTAL_COMPONENTS_HPP Chris@16: Chris@16: #include Chris@16: Chris@16: namespace boost { Chris@16: Chris@16: namespace detail { Chris@16: Chris@16: // Iterator for a component index linked list. The contents of Chris@16: // each array element represent the next index in the list. A Chris@16: // special value (the maximum index + 1) is used to terminate a Chris@16: // list. Chris@16: template Chris@16: class component_index_iterator : Chris@16: boost::forward_iterator_helper, Chris@16: typename std::iterator_traits::value_type, Chris@16: typename std::iterator_traits::difference_type, Chris@16: typename std::iterator_traits::pointer, Chris@16: typename std::iterator_traits::reference> { Chris@16: Chris@16: private: Chris@16: typedef component_index_iterator self; Chris@16: Chris@16: public: Chris@16: typedef std::forward_iterator_tag iterator_category; Chris@16: typedef typename std::iterator_traits::value_type value_type; Chris@16: typedef typename std::iterator_traits::difference_type reference; Chris@16: typedef typename std::iterator_traits::pointer pointer; Chris@16: typedef typename std::iterator_traits::reference difference_type; Chris@16: Chris@16: // Constructor for "begin" iterator Chris@16: component_index_iterator(IndexRandomAccessIterator index_iterator, Chris@16: value_type begin_index) : Chris@16: m_index_iterator(index_iterator), Chris@16: m_current_index(begin_index) { } Chris@16: Chris@16: // Constructor for "end" iterator (end_index should be the linked Chris@16: // list terminator). Chris@16: component_index_iterator(value_type end_index) : Chris@16: m_current_index(end_index) { } Chris@16: Chris@16: inline value_type operator*() const { Chris@16: return (m_current_index); Chris@16: } Chris@16: Chris@16: self& operator++() { Chris@16: // Move to the next element in the linked list Chris@16: m_current_index = m_index_iterator[m_current_index]; Chris@16: return (*this); Chris@16: } Chris@16: Chris@16: bool operator==(const self& other_iterator) const { Chris@16: return (m_current_index == *other_iterator); Chris@16: } Chris@16: Chris@16: protected: Chris@16: IndexRandomAccessIterator m_index_iterator; Chris@16: value_type m_current_index; Chris@16: Chris@16: }; // class component_index_iterator Chris@16: Chris@16: } // namespace detail Chris@16: Chris@16: } // namespace detail Chris@16: Chris@16: #endif // BOOST_GRAPH_DETAIL_INCREMENTAL_COMPONENTS_HPP