annotate DEPENDENCIES/generic/include/boost/graph/property_maps/container_property_map.hpp @ 125:34e428693f5d vext

Vext -> Repoint
author Chris Cannam
date Thu, 14 Jun 2018 11:15:39 +0100
parents 2665513ce2d3
children
rev   line source
Chris@16 1 // (C) Copyright 2007-2009 Andrew Sutton
Chris@16 2 //
Chris@16 3 // Use, modification and distribution are subject to the
Chris@16 4 // Boost Software License, Version 1.0 (See accompanying file
Chris@16 5 // LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
Chris@16 6
Chris@16 7 #ifndef BOOST_GRAPH_CONTAINER_PROPERTY_MAP_HPP
Chris@16 8 #define BOOST_GRAPH_CONTAINER_PROPERTY_MAP_HPP
Chris@16 9
Chris@16 10 #include <boost/graph/detail/index.hpp>
Chris@16 11 #include <boost/property_map/property_map.hpp>
Chris@16 12
Chris@16 13 namespace boost
Chris@16 14 {
Chris@16 15 // This is an adapter built over the iterator property map with
Chris@16 16 // more useful uniform construction semantics. Specifically, this
Chris@16 17 // requires the container rather than the iterator and the graph
Chris@16 18 // rather than the optional index map.
Chris@16 19 template <typename Graph, typename Key, typename Container>
Chris@16 20 struct container_property_map
Chris@16 21 : public boost::put_get_helper<
Chris@16 22 typename iterator_property_map<
Chris@16 23 typename Container::iterator,
Chris@16 24 typename property_map<
Chris@16 25 Graph,
Chris@16 26 typename detail::choose_indexer<Graph, Key>::index_type
Chris@16 27 >::type
Chris@16 28 >::reference,
Chris@16 29 container_property_map<Graph, Key, Container>
Chris@16 30 >
Chris@16 31 {
Chris@16 32 typedef typename detail::choose_indexer<Graph, Key>::indexer_type indexer_type;
Chris@16 33 typedef typename indexer_type::index_type index_type;
Chris@16 34 typedef iterator_property_map<
Chris@16 35 typename Container::iterator,
Chris@16 36 typename property_map<Graph, index_type>::type
Chris@16 37 > map_type;
Chris@16 38 typedef typename map_type::key_type key_type;
Chris@16 39 typedef typename map_type::value_type value_type;
Chris@16 40 typedef typename map_type::reference reference;
Chris@16 41 typedef typename map_type::category category;
Chris@16 42
Chris@16 43 // The default constructor will *probably* crash if its actually
Chris@16 44 // used for referencing vertices since the underlying iterator
Chris@16 45 // map points past the end of an unknown container.
Chris@16 46 inline container_property_map()
Chris@16 47 : m_map()
Chris@16 48 { }
Chris@16 49
Chris@16 50 // This is the preferred constructor. It is invoked over the container
Chris@16 51 // and the graph explicitly. This requires that the underlying iterator
Chris@16 52 // map use the indices of the vertices in g rather than the default
Chris@16 53 // identity map.
Chris@16 54 //
Chris@16 55 // Note the const-cast this ensures the reference type of the
Chris@16 56 // vertex index map is non-const, which happens to be an
Chris@16 57 // artifact of passing const graph references.
Chris@16 58 inline container_property_map(Container& c, const Graph& g)
Chris@16 59 : m_map(c.begin(), indexer_type::index_map(const_cast<Graph&>(g)))
Chris@16 60 { }
Chris@16 61
Chris@16 62 // Typical copy constructor.
Chris@16 63 inline container_property_map(const container_property_map& x)
Chris@16 64 : m_map(x.m_map)
Chris@16 65 { }
Chris@16 66
Chris@16 67 // The [] operator delegates to the underlying map/
Chris@16 68 inline reference operator [](const key_type& k) const
Chris@16 69 { return m_map[k]; }
Chris@16 70
Chris@16 71 map_type m_map;
Chris@16 72 };
Chris@16 73 }
Chris@16 74
Chris@16 75 #endif