Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 09:58:06

0001 // (C) Copyright Jeremy Siek, 2001.
0002 // Distributed under the Boost Software License, Version 1.0. (See
0003 // accompanying file LICENSE_1_0.txt or copy at
0004 // http://www.boost.org/LICENSE_1_0.txt)
0005 
0006 //  See http://www.boost.org/libs/property_map for documentation.
0007 
0008 #ifndef BOOST_PROPERTY_MAP_ITERATOR_HPP
0009 #define BOOST_PROPERTY_MAP_ITERATOR_HPP
0010 
0011 #include <boost/property_map/property_map.hpp>
0012 #include <boost/iterator/iterator_adaptor.hpp>
0013 #include <boost/mpl/if.hpp>
0014 #include <boost/type_traits/is_same.hpp>
0015 
0016 namespace boost {
0017 
0018   //======================================================================
0019   // property iterator, generalized from ideas by Francois Faure
0020 
0021   namespace detail {
0022 
0023     template <class Iterator, class LvaluePropertyMap>
0024     class lvalue_pmap_iter
0025       : public iterator_adaptor< lvalue_pmap_iter< Iterator, LvaluePropertyMap >,
0026                                  Iterator,
0027                                  typename property_traits<LvaluePropertyMap>::value_type,
0028                                  use_default,
0029                                  typename property_traits<LvaluePropertyMap>::reference>
0030     {
0031       friend class boost::iterator_core_access;
0032 
0033       typedef iterator_adaptor< lvalue_pmap_iter< Iterator, LvaluePropertyMap >,
0034                                 Iterator,
0035                                 typename property_traits<LvaluePropertyMap>::value_type,
0036                                 use_default,
0037                                 typename property_traits<LvaluePropertyMap>::reference> super_t;
0038 
0039     public:
0040       lvalue_pmap_iter() { }
0041       lvalue_pmap_iter(Iterator const&     it,
0042                        LvaluePropertyMap m)
0043         : super_t(it),
0044           m_map(m) {}
0045 
0046     private:
0047       typename super_t::reference
0048       dereference() const
0049       {
0050         return m_map[*(this->base_reference())];
0051       }
0052 
0053       LvaluePropertyMap m_map;
0054     };
0055 
0056     template <class Iterator, class ReadablePropertyMap>
0057     class readable_pmap_iter :
0058       public iterator_adaptor< readable_pmap_iter< Iterator, ReadablePropertyMap >,
0059                                Iterator,
0060                                typename property_traits<ReadablePropertyMap>::value_type,
0061                                use_default,
0062                                typename property_traits<ReadablePropertyMap>::value_type>
0063 
0064 
0065     {
0066       friend class boost::iterator_core_access;
0067 
0068       typedef iterator_adaptor< readable_pmap_iter< Iterator, ReadablePropertyMap >,
0069                                 Iterator,
0070                                 typename property_traits<ReadablePropertyMap>::value_type,
0071                                 use_default,
0072                                 typename property_traits<ReadablePropertyMap>::value_type> super_t;
0073 
0074     public:
0075       readable_pmap_iter() { }
0076       readable_pmap_iter(Iterator const&     it,
0077                          ReadablePropertyMap m)
0078         : super_t(it),
0079           m_map(m) {}
0080 
0081     private:
0082       typename super_t::reference
0083       dereference() const
0084       {
0085         return get(m_map, *(this->base_reference()));
0086       }
0087 
0088       ReadablePropertyMap m_map;
0089     };
0090 
0091 
0092   } // namespace detail
0093 
0094   template <class PropertyMap, class Iterator>
0095   struct property_map_iterator_generator :
0096     mpl::if_< is_same< typename property_traits<PropertyMap>::category, lvalue_property_map_tag>,
0097               detail::lvalue_pmap_iter<Iterator, PropertyMap>,
0098               detail::readable_pmap_iter<Iterator, PropertyMap> >
0099   {};
0100 
0101   template <class PropertyMap, class Iterator>
0102   typename property_map_iterator_generator<PropertyMap, Iterator>::type
0103   make_property_map_iterator(PropertyMap pmap, Iterator iter)
0104   {
0105     typedef typename property_map_iterator_generator<PropertyMap, 
0106       Iterator>::type Iter;
0107     return Iter(iter, pmap);
0108   }
0109 
0110 } // namespace boost
0111 
0112 #endif // BOOST_PROPERTY_MAP_ITERATOR_HPP
0113