Commit d0a73fff authored by Tiago Peixoto's avatar Tiago Peixoto

Rename fast_vector_property_map to checked_vector_property_map

This makes the naming more sensible.
parent bd6ebfb7
......@@ -39,14 +39,14 @@
namespace boost {
template<typename T, typename IndexMap>
class unchecked_fast_vector_property_map;
class unchecked_vector_property_map;
template<typename T, typename IndexMap = identity_property_map>
class fast_vector_property_map
class checked_vector_property_map
: public boost::put_get_helper<
typename std::iterator_traits<
typename std::vector<T>::iterator >::reference,
fast_vector_property_map<T, IndexMap> >
checked_vector_property_map<T, IndexMap> >
{
public:
typedef typename property_traits<IndexMap>::key_type key_type;
......@@ -56,20 +56,21 @@ public:
typedef boost::lvalue_property_map_tag category;
template<typename Type, typename Index>
friend class unchecked_fast_vector_property_map;
friend class unchecked_vector_property_map;
typedef unchecked_fast_vector_property_map<T, IndexMap> unchecked_t;
typedef unchecked_vector_property_map<T, IndexMap> unchecked_t;
typedef IndexMap index_map_t;
typedef fast_vector_property_map<T,IndexMap> self_t;
typedef checked_vector_property_map<T,IndexMap> self_t;
fast_vector_property_map(const IndexMap& index = IndexMap())
: store(new std::vector<T>()), index(index)
{}
checked_vector_property_map(const IndexMap& index = IndexMap())
: store(new std::vector<T>()), index(index) {}
fast_vector_property_map(unsigned initial_size,
const IndexMap& index = IndexMap())
: store(new std::vector<T>(initial_size)), index(index)
{}
checked_vector_property_map(unsigned initial_size,
const IndexMap& index = IndexMap())
: store(new std::vector<T>(initial_size)), index(index) {}
checked_vector_property_map(const unchecked_t& map)
: checked_vector_property_map(map.get_checked()) {}
typename std::vector<T>::iterator storage_begin()
{
......@@ -93,6 +94,7 @@ public:
void reserve(size_t size) const
{
#pragma omp critical
if (store->size() < size)
store->resize(size);
}
......@@ -129,11 +131,11 @@ protected:
};
template<typename T, typename IndexMap = identity_property_map>
class unchecked_fast_vector_property_map
class unchecked_vector_property_map
: public boost::put_get_helper<
typename std::iterator_traits<
typename std::vector<T>::iterator >::reference,
unchecked_fast_vector_property_map<T, IndexMap> >
unchecked_vector_property_map<T, IndexMap> >
{
public:
typedef typename property_traits<IndexMap>::key_type key_type;
......@@ -142,35 +144,51 @@ public:
typename std::vector<T>::iterator >::reference reference;
typedef boost::lvalue_property_map_tag category;
typedef fast_vector_property_map<T, IndexMap> vmap_t;
typedef checked_vector_property_map<T, IndexMap> checked_t;
unchecked_vector_property_map(const checked_t& checked = checked_t(),
size_t size = 0)
: _checked(checked)
{
if (size > 0 && _checked.store->size() < size)
_checked.store->resize(size);
}
unchecked_fast_vector_property_map(const vmap_t& vmap = vmap_t(),
size_t size = 0)
: _vmap(vmap)
unchecked_vector_property_map(const IndexMap& index_map,
size_t size = 0)
{
if (size > 0 && _vmap.store->size() < size)
_vmap.store->resize(size);
*this = unchecked_vector_property_map(checked_t(index_map), size);
}
void reserve(size_t size) const { _vmap.reserve(size); }
void reserve(size_t size) const { _checked.reserve(size); }
reference operator[](const key_type& v) const
{
typename property_traits<IndexMap>::value_type i =
get(_vmap.index, v);
return (*_vmap.store)[i];
get(_checked.index, v);
return (*_checked.store)[i];
}
private:
std::vector<T>& get_storage() const { return _checked.get_storage(); }
checked_t get_checked() {return _checked;}
vmap_t _vmap;
private:
checked_t _checked;
};
template<typename T, typename IndexMap>
fast_vector_property_map<T, IndexMap>
make_fast_vector_property_map(IndexMap index)
checked_vector_property_map<T, IndexMap>
make_checked_vector_property_map(IndexMap index)
{
return checked_vector_property_map<T, IndexMap>(index);
}
template<typename T, typename IndexMap>
unchecked_vector_property_map<T, IndexMap>
make_unchecked_vector_property_map(IndexMap index)
{
return fast_vector_property_map<T, IndexMap>(index);
return unchecked_vector_property_map<T, IndexMap>(index);
}
}
......
......@@ -202,14 +202,14 @@ private:
graph_index_map_t _graph_index;
// vertex filter
typedef unchecked_fast_vector_property_map<uint8_t,vertex_index_map_t>
typedef unchecked_vector_property_map<uint8_t,vertex_index_map_t>
vertex_filter_t;
vertex_filter_t _vertex_filter_map;
bool _vertex_filter_invert;
bool _vertex_filter_active;
// edge filter
typedef unchecked_fast_vector_property_map<uint8_t,edge_index_map_t> edge_filter_t;
typedef unchecked_vector_property_map<uint8_t,edge_index_map_t> edge_filter_t;
edge_filter_t _edge_filter_map;
bool _edge_filter_invert;
bool _edge_filter_active;
......
......@@ -279,7 +279,7 @@ void GraphInterface::SetVertexFilterProperty(boost::any property, bool invert)
try
{
_vertex_filter_map =
any_cast<vertex_filter_t::vmap_t>(property).get_unchecked();
any_cast<vertex_filter_t::checked_t>(property).get_unchecked();
_vertex_filter_invert = invert;
_vertex_filter_active = true;
}
......@@ -298,7 +298,7 @@ void GraphInterface::SetEdgeFilterProperty(boost::any property, bool invert)
try
{
_edge_filter_map =
any_cast<edge_filter_t::vmap_t>(property).get_unchecked();
any_cast<edge_filter_t::checked_t>(property).get_unchecked();
_edge_filter_invert = invert;
_edge_filter_active = true;
}
......
......@@ -501,18 +501,18 @@ struct action_wrap
: _a(a), _max_v(max_v), _max_e(max_e) {}
template <class Type>
typename fast_vector_property_map
typename checked_vector_property_map
<Type,GraphInterface::vertex_index_map_t>::unchecked_t
uncheck(fast_vector_property_map
uncheck(checked_vector_property_map
<Type,GraphInterface::vertex_index_map_t> a) const
{
return a.get_unchecked(_max_v);
}
template <class Type>
typename fast_vector_property_map
typename checked_vector_property_map
<Type,GraphInterface::edge_index_map_t>::unchecked_t
uncheck(fast_vector_property_map
uncheck(checked_vector_property_map
<Type,GraphInterface::edge_index_map_t> a) const
{
return a.get_unchecked(_max_e);
......
......@@ -99,7 +99,7 @@ struct property_map_type
template <class ValueType, class IndexMap>
struct apply
{
typedef fast_vector_property_map<ValueType,IndexMap> type;
typedef checked_vector_property_map<ValueType,IndexMap> type;
};
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment