Added boost header

This commit is contained in:
Christophe Riccio
2012-01-08 01:26:07 +00:00
parent 9c3faaca40
commit c7d752cdf8
8946 changed files with 1732316 additions and 0 deletions

View File

@@ -0,0 +1,59 @@
// (C) Copyright 2007-2009 Andrew Sutton
//
// Use, modification and distribution are subject to the
// Boost Software License, Version 1.0 (See accompanying file
// LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_GRAPH_CONSTANT_PROPERTY_HPP
#define BOOST_GRAPH_CONSTANT_PROPERTY_HPP
#include <boost/property_map/property_map.hpp>
// TODO: This should really be part of the property maps library rather than
// the Boost.Graph library.
namespace boost {
/**
* A constant property is one, that regardless of the edge or vertex given,
* will always return a constant value.
*/
template <typename Key, typename Value>
struct constant_property_map
: public boost::put_get_helper<
const Value&,
constant_property_map<Key, Value>
>
{
typedef Key key_type;
typedef Value value_type;
typedef const Value& reference;
typedef boost::readable_property_map_tag category;
constant_property_map()
: m_value()
{ }
constant_property_map(const value_type &value)
: m_value(value)
{ }
constant_property_map(const constant_property_map& copy)
: m_value(copy.m_value)
{ }
inline reference operator [](const key_type&) const
{ return m_value; }
value_type m_value;
};
template <typename Key, typename Value>
inline constant_property_map<Key, Value>
make_constant_property(const Value& value)
{ return constant_property_map<Key, Value>(value); }
} /* namespace boost */
#endif

View File

@@ -0,0 +1,75 @@
// (C) Copyright 2007-2009 Andrew Sutton
//
// Use, modification and distribution are subject to the
// Boost Software License, Version 1.0 (See accompanying file
// LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_GRAPH_CONTAINER_PROPERTY_MAP_HPP
#define BOOST_GRAPH_CONTAINER_PROPERTY_MAP_HPP
#include <boost/graph/detail/index.hpp>
#include <boost/property_map/property_map.hpp>
namespace boost
{
// This is an adapter built over the iterator property map with
// more useful uniform construction semantics. Specifically, this
// requires the container rather than the iterator and the graph
// rather than the optional index map.
template <typename Graph, typename Key, typename Container>
struct container_property_map
: public boost::put_get_helper<
typename iterator_property_map<
typename Container::iterator,
typename property_map<
Graph,
typename detail::choose_indexer<Graph, Key>::index_type
>::type
>::reference,
container_property_map<Graph, Key, Container>
>
{
typedef typename detail::choose_indexer<Graph, Key>::indexer_type indexer_type;
typedef typename indexer_type::index_type index_type;
typedef iterator_property_map<
typename Container::iterator,
typename property_map<Graph, index_type>::type
> map_type;
typedef typename map_type::key_type key_type;
typedef typename map_type::value_type value_type;
typedef typename map_type::reference reference;
typedef typename map_type::category category;
// The default constructor will *probably* crash if its actually
// used for referencing vertices since the underlying iterator
// map points past the end of an unknown container.
inline container_property_map()
: m_map()
{ }
// This is the preferred constructor. It is invoked over the container
// and the graph explicitly. This requires that the underlying iterator
// map use the indices of the vertices in g rather than the default
// identity map.
//
// Note the const-cast this ensures the reference type of the
// vertex index map is non-const, which happens to be an
// artifact of passing const graph references.
inline container_property_map(Container& c, const Graph& g)
: m_map(c.begin(), indexer_type::index_map(const_cast<Graph&>(g)))
{ }
// Typical copy constructor.
inline container_property_map(const container_property_map& x)
: m_map(x.m_map)
{ }
// The [] operator delegates to the underlying map/
inline reference operator [](const key_type& k) const
{ return m_map[k]; }
map_type m_map;
};
}
#endif

View File

@@ -0,0 +1,67 @@
// (C) Copyright 2007-2009 Andrew Sutton
//
// Use, modification and distribution are subject to the
// Boost Software License, Version 1.0 (See accompanying file
// LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_GRAPH_MATRIX_PROPERTY_MAP_HPP
#define BOOST_GRAPH_MATRIX_PROPERTY_MAP_HPP
#include <boost/graph/property_maps/container_property_map.hpp>
namespace boost
{
// This property map is built specifically for property maps over
// matrices. Like the basic property map over a container, this builds
// the property abstraction over a matrix (usually a vector of vectors)
// and returns property maps over the nested containers.
template <typename Graph, typename Key, typename Matrix>
struct matrix_property_map
: boost::put_get_helper<
container_property_map<Graph, Key, typename Matrix::value_type>,
matrix_property_map<Graph, Key, Matrix> >
{
// abstract the indexing keys
typedef typename detail::choose_indexer<Graph, Key>::indexer_type indexer_type;
// aliases for the nested container and its corresponding map
typedef typename Matrix::value_type container_type;
typedef container_property_map<Graph, Key, container_type> map_type;
typedef Key key_type;
// This property map doesn't really provide access to nested containers,
// but returns property maps over them. Since property maps are all
// copy-constructible (or should be anyways), we never return references.
// As such, this property is only readable, but not writable. Curiously,
// the inner property map is actually an lvalue pmap.
typedef map_type value_type;
typedef map_type reference;
typedef readable_property_map_tag category;
matrix_property_map()
: m_matrix(0), m_graph(0)
{ }
matrix_property_map(Matrix& m, const Graph& g)
: m_matrix(&m), m_graph(const_cast<Graph*>(&g))
{ }
matrix_property_map(const matrix_property_map& x)
: m_matrix(x.m_matrix), m_graph(x.m_graph)
{ }
inline reference operator [](key_type k) const
{
typedef typename indexer_type::value_type Index;
Index x = indexer_type::index(k, *m_graph);
return map_type((*m_matrix)[x], *m_graph);
}
private:
mutable Matrix* m_matrix;
mutable Graph* m_graph;
};
}
#endif

View File

@@ -0,0 +1,41 @@
// (C) Copyright Andrew Sutton 2007
//
// Use, modification and distribution are subject to the
// Boost Software License, Version 1.0 (See accompanying file
// LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_GRAPH_NULL_PROPERTY_HPP
#define BOOST_GRAPH_NULL_PROPERTY_HPP
#include <boost/property_map/property_map.hpp>
// TODO: This should really be part of the property maps library rather than
// the Boost.Graph library.
namespace boost
{
// A null property is somewhat like the inverse of the constant
// property map except that instead of returning a single value,
// this eats any writes and cannot be read from.
template <typename Key, typename Value>
struct null_property_map
{
typedef Key key_type;
typedef Value value_type;
typedef void reference;
typedef boost::writable_property_map_tag category;
};
// The null_property_map<K,V> only has a put() function.
template <typename K, typename V>
void put(null_property_map<K,V>& pm, const K& key, const V& value)
{ }
// A helper function for intantiating null property maps.
template <typename Key, typename Value>
inline null_property_map<Key, Value> make_null_property()
{ return null_property_map<Key, Value>(); }
}
#endif