Commit 2536f2a5 authored by Tiago Peixoto's avatar Tiago Peixoto
Browse files

Removed forced inlines and add some C++14 mannerisms

parent 423177ce
Pipeline #31 failed with stage
......@@ -171,10 +171,9 @@ public:
void reserve(size_t size) const { _checked.reserve(size); }
reference operator[](const key_type& v) const __attribute__((always_inline))
reference operator[](const key_type& v) const
{
typename property_traits<IndexMap>::value_type i =
get(_checked.index, v);
auto i = get(_checked.index, v);
return (*_checked.store)[i];
}
......
......@@ -298,7 +298,7 @@ target(const typename graph_traits<UndirectedAdaptor<Graph> >::edge_descriptor&
// vertex(n,g)
//==============================================================================
template <class Graph>
inline __attribute__((always_inline))
inline
typename graph_traits<UndirectedAdaptor<Graph> >::vertex_descriptor
vertex(typename graph_traits<UndirectedAdaptor<Graph> >::vertices_size_type n,
const UndirectedAdaptor<Graph>& g)
......@@ -310,7 +310,7 @@ vertex(typename graph_traits<UndirectedAdaptor<Graph> >::vertices_size_type n,
// vertices(g)
//==============================================================================
template <class Graph>
inline __attribute__((always_inline))
inline
std::pair<typename graph_traits<UndirectedAdaptor<Graph> >::vertex_iterator,
typename graph_traits<UndirectedAdaptor<Graph> >::vertex_iterator >
vertices(const UndirectedAdaptor<Graph>& g)
......@@ -322,7 +322,7 @@ vertices(const UndirectedAdaptor<Graph>& g)
// edges(g)
//==============================================================================
template <class Graph>
inline __attribute__((always_inline))
inline
std::pair<typename graph_traits<UndirectedAdaptor<Graph> >::edge_iterator,
typename graph_traits<UndirectedAdaptor<Graph> >::edge_iterator >
edges(const UndirectedAdaptor<Graph>& g)
......@@ -334,7 +334,7 @@ edges(const UndirectedAdaptor<Graph>& g)
// edge(u, v, g)
//==============================================================================
template <class Graph>
inline __attribute__((always_inline))
inline
std::pair<typename graph_traits<UndirectedAdaptor<Graph> >::edge_descriptor,
bool>
edge(typename graph_traits<UndirectedAdaptor<Graph> >::vertex_descriptor u,
......@@ -356,7 +356,7 @@ edge(typename graph_traits<UndirectedAdaptor<Graph> >::vertex_descriptor u,
// out_edges(u,g)
//==============================================================================
template <class Graph>
inline __attribute__((always_inline))
inline
std::pair<typename graph_traits<UndirectedAdaptor<Graph> >::out_edge_iterator,
typename graph_traits<UndirectedAdaptor<Graph> >::out_edge_iterator >
out_edges(typename graph_traits<UndirectedAdaptor<Graph> >::vertex_descriptor u,
......@@ -375,7 +375,7 @@ out_edges(typename graph_traits<UndirectedAdaptor<Graph> >::vertex_descriptor u,
// in_edges(u,g)
//==============================================================================
template <class Graph>
inline __attribute__((always_inline))
inline
std::pair<typename graph_traits<UndirectedAdaptor<Graph> >::in_edge_iterator,
typename graph_traits<UndirectedAdaptor<Graph> >::in_edge_iterator >
in_edges(typename graph_traits<UndirectedAdaptor<Graph> >::vertex_descriptor u,
......@@ -394,7 +394,7 @@ in_edges(typename graph_traits<UndirectedAdaptor<Graph> >::vertex_descriptor u,
// adjacent_vertices(u,g)
//==============================================================================
template <class Graph>
inline __attribute__((always_inline))
inline
std::pair<typename graph_traits<UndirectedAdaptor<Graph> >::adjacency_iterator,
typename graph_traits<UndirectedAdaptor<Graph> >::adjacency_iterator>
adjacent_vertices
......@@ -414,7 +414,7 @@ adjacent_vertices
// num_vertices(g)
//==============================================================================
template <class Graph>
inline __attribute__((always_inline))
inline
typename graph_traits<UndirectedAdaptor<Graph> >::vertices_size_type
num_vertices(const UndirectedAdaptor<Graph>& g)
{
......@@ -435,7 +435,7 @@ num_edges(const UndirectedAdaptor<Graph>& g)
// out_degree(u,g)
//==============================================================================
template <class Graph>
inline __attribute__((always_inline))
inline
typename graph_traits<UndirectedAdaptor<Graph> >::degree_size_type
out_degree(typename graph_traits<UndirectedAdaptor<Graph> >::vertex_descriptor u,
const UndirectedAdaptor<Graph>& g)
......@@ -447,7 +447,7 @@ out_degree(typename graph_traits<UndirectedAdaptor<Graph> >::vertex_descriptor u
// in_degree(u,g)
//==============================================================================
template <class Graph>
inline __attribute__((always_inline))
inline
typename graph_traits<UndirectedAdaptor<Graph> >::degree_size_type
in_degree(typename graph_traits<UndirectedAdaptor<Graph> >::vertex_descriptor u,
const UndirectedAdaptor<Graph>& g)
......@@ -459,7 +459,7 @@ in_degree(typename graph_traits<UndirectedAdaptor<Graph> >::vertex_descriptor u,
// degree(u,g)
//==============================================================================
template <class Graph>
inline __attribute__((always_inline))
inline
typename graph_traits<UndirectedAdaptor<Graph> >::degree_size_type
degree(typename graph_traits<UndirectedAdaptor<Graph> >::vertex_descriptor u,
const UndirectedAdaptor<Graph>& g)
......@@ -472,7 +472,7 @@ degree(typename graph_traits<UndirectedAdaptor<Graph> >::vertex_descriptor u,
// add_vertex(g)
//==============================================================================
template <class Graph>
inline __attribute__((always_inline))
inline
typename graph_traits<UndirectedAdaptor<Graph> >::vertex_descriptor
add_vertex(UndirectedAdaptor<Graph>& g)
{
......@@ -493,7 +493,7 @@ add_vertex(const VertexProperties& p, UndirectedAdaptor<Graph>& g)
// clear_vertex(u,g)
//==============================================================================
template <class Graph>
inline __attribute__((always_inline))
inline
void clear_vertex(typename graph_traits<UndirectedAdaptor<Graph> >::vertex_descriptor u,
UndirectedAdaptor<Graph>& g)
{
......@@ -504,7 +504,7 @@ void clear_vertex(typename graph_traits<UndirectedAdaptor<Graph> >::vertex_descr
// remove_vertex(u,g)
//==============================================================================
template <class Graph>
inline __attribute__((always_inline))
inline
void remove_vertex(typename graph_traits<UndirectedAdaptor<Graph> >::vertex_descriptor u,
UndirectedAdaptor<Graph>& g)
{
......@@ -515,7 +515,7 @@ void remove_vertex(typename graph_traits<UndirectedAdaptor<Graph> >::vertex_desc
// remove_vertex_fast(u,g)
//==============================================================================
template <class Graph>
inline __attribute__((always_inline))
inline
void remove_vertex_fast(typename graph_traits<UndirectedAdaptor<Graph> >::vertex_descriptor u,
UndirectedAdaptor<Graph>& g)
{
......@@ -526,7 +526,7 @@ void remove_vertex_fast(typename graph_traits<UndirectedAdaptor<Graph> >::vertex
// add_edge(u,v,g)
//==============================================================================
template <class Graph>
inline __attribute__((always_inline))
inline
std::pair<typename graph_traits<UndirectedAdaptor<Graph> >::edge_descriptor,
bool>
add_edge(typename graph_traits<UndirectedAdaptor<Graph> >::vertex_descriptor u,
......@@ -540,7 +540,7 @@ add_edge(typename graph_traits<UndirectedAdaptor<Graph> >::vertex_descriptor u,
// add_edge(u,v,ep,g)
//==============================================================================
template <class Graph, class EdgeProperties>
inline __attribute__((always_inline))
inline
std::pair<typename graph_traits<UndirectedAdaptor<Graph> >::edge_descriptor,
bool>
add_edge(typename graph_traits<UndirectedAdaptor<Graph> >::vertex_descriptor u,
......@@ -554,7 +554,7 @@ add_edge(typename graph_traits<UndirectedAdaptor<Graph> >::vertex_descriptor u,
// remove_edge(u,v,g)
//==============================================================================
template <class Graph>
inline __attribute__((always_inline))
inline
void remove_edge(typename graph_traits<UndirectedAdaptor<Graph> >::vertex_descriptor u,
typename graph_traits<UndirectedAdaptor<Graph> >::vertex_descriptor v,
UndirectedAdaptor<Graph>& g)
......@@ -567,7 +567,7 @@ void remove_edge(typename graph_traits<UndirectedAdaptor<Graph> >::vertex_descri
// remove_edge(e,g)
//==============================================================================
template <class Graph>
inline __attribute__((always_inline))
inline
void remove_edge (typename graph_traits<UndirectedAdaptor<Graph> >::edge_descriptor e,
UndirectedAdaptor<Graph>& g)
{
......@@ -578,7 +578,7 @@ void remove_edge (typename graph_traits<UndirectedAdaptor<Graph> >::edge_descrip
// remove_edge(e_iter,g)
//==============================================================================
template <class Graph>
inline __attribute__((always_inline))
inline
void remove_edge(typename graph_traits<UndirectedAdaptor<Graph> >::out_edge_iterator iter,
UndirectedAdaptor<Graph>& g)
{
......@@ -589,7 +589,7 @@ void remove_edge(typename graph_traits<UndirectedAdaptor<Graph> >::out_edge_iter
// remove_out_edge_if(v,predicate,g)
//==============================================================================
template <class Graph, class Predicate>
inline __attribute__((always_inline))
inline
void remove_out_edge_if(typename graph_traits<UndirectedAdaptor<Graph> >::vertex_descriptor v,
Predicate predicate, UndirectedAdaptor<Graph>& g)
{
......@@ -606,7 +606,7 @@ void remove_out_edge_if(typename graph_traits<UndirectedAdaptor<Graph> >::vertex
// remove_in_edge_if(v,predicate,g)
//==============================================================================
template <class Graph, class Predicate>
inline __attribute__((always_inline))
inline
void remove_in_edge_if(typename graph_traits<UndirectedAdaptor<Graph> >::vertex_descriptor v,
Predicate predicate, UndirectedAdaptor<Graph>& g)
{
......@@ -691,7 +691,7 @@ public:
// get(tag,g)
//==============================================================================
template <class PropertyTag, class Graph>
inline __attribute__((always_inline))
inline
typename property_map<UndirectedAdaptor<Graph>, PropertyTag>::type
get(PropertyTag tag, UndirectedAdaptor<Graph>& g)
{
......@@ -702,7 +702,7 @@ get(PropertyTag tag, UndirectedAdaptor<Graph>& g)
// const get(tag,g)
//==============================================================================
template <class PropertyTag, class Graph>
inline __attribute__((always_inline))
inline
typename property_map<UndirectedAdaptor<Graph>, PropertyTag>::const_type
get(PropertyTag tag, const UndirectedAdaptor<Graph>& g)
{
......@@ -713,7 +713,7 @@ get(PropertyTag tag, const UndirectedAdaptor<Graph>& g)
// get(tag,g,v)
//==============================================================================
template <class PropertyTag, class Graph>
inline __attribute__((always_inline))
inline
typename property_traits
<typename property_map<UndirectedAdaptor<Graph>,
PropertyTag>::const_type >::value_type
......@@ -727,7 +727,7 @@ get(PropertyTag tag, const UndirectedAdaptor<Graph>& g,
// get(tag,g,e)
//==============================================================================
template <class PropertyTag, class Graph>
inline __attribute__((always_inline))
inline
typename property_traits
<typename property_map<UndirectedAdaptor<Graph>,
PropertyTag>::const_type >::value_type
......@@ -741,7 +741,7 @@ get(PropertyTag tag, const UndirectedAdaptor<Graph>& g,
// put(tag, g, v, value)
//==============================================================================
template <class Graph, class PropertyTag, class Value>
inline __attribute__((always_inline))
inline
void put(PropertyTag tag, UndirectedAdaptor<Graph>& g,
typename graph_traits<UndirectedAdaptor<Graph> >::vertex_descriptor v,
const Value& value)
......@@ -753,7 +753,7 @@ void put(PropertyTag tag, UndirectedAdaptor<Graph>& g,
// put(tag, g, e, value)
//==============================================================================
template <class Graph, class PropertyTag, class X, class Value>
inline __attribute__((always_inline))
inline
void put(PropertyTag tag, const UndirectedAdaptor<Graph>& g,
typename graph_traits<UndirectedAdaptor<Graph> >::edge_descriptor e,
const Value &value)
......@@ -765,7 +765,7 @@ void put(PropertyTag tag, const UndirectedAdaptor<Graph>& g,
// get_property(g,tag)
//==============================================================================
template <class Graph, class GraphProperties, class GraphPropertyTag>
inline __attribute__((always_inline))
inline
typename property_value<GraphProperties, GraphPropertyTag>::type&
get_property(UndirectedAdaptor<Graph>& g, GraphPropertyTag tag)
{
......@@ -776,7 +776,7 @@ get_property(UndirectedAdaptor<Graph>& g, GraphPropertyTag tag)
// const get_property(g,tag)
//==============================================================================
template <class Graph, class GraphProperties, class GraphPropertyTag>
inline __attribute__((always_inline))
inline
const typename property_value<GraphProperties, GraphPropertyTag>::type&
get_property(const UndirectedAdaptor<Graph>& g, GraphPropertyTag tag)
{
......
......@@ -266,14 +266,17 @@ public:
_in_edges.clear();
_in_edges.resize(_out_edges.size());
for (size_t i = 0; i < _out_edges.size(); ++i)
{
auto& oes = _out_edges[i];
for (size_t j = 0; j < _out_edges[i].size(); ++j)
{
auto& oe = _out_edges[i][j];
auto& oe = oes[j];
Vertex v = oe.first;
oe.second = _last_idx;
_in_edges[v].emplace_back(i, _last_idx);
_last_idx++;
}
}
if (_keep_epos)
rebuild_epos();
......@@ -320,13 +323,15 @@ private:
_epos.resize(_last_idx + 1);
for (size_t i = 0; i < _out_edges.size(); ++i)
{
for (size_t j = 0; j < _out_edges[i].size(); ++j)
auto& oes = _out_edges[i];
for (size_t j = 0; j < oes.size(); ++j)
{
size_t idx = _out_edges[i][j].second;
size_t idx = oes[j].second;
_epos[idx].first = j;
}
for (size_t j = 0; j < _in_edges[i].size(); ++j)
auto& ies = _in_edges[i];
for (size_t j = 0; j < ies.size(); ++j)
{
size_t idx = _in_edges[i][j].second;
_epos[idx].second = j;
......@@ -835,26 +840,22 @@ inline void remove_edge(const typename adj_list<Vertex>::edge_descriptor& e,
bool found = false;
if (!g._keep_epos) // O(k_s + k_t)
{
for (size_t i = 0; i < oes.size(); ++i)
auto iter_o = std::find_if(oes.begin(), oes.end(),
[&] (const auto& ei) -> bool
{return t == ei.first && idx == ei.second;});
if (iter_o != oes.end())
{
const auto& ei = oes[i];
if (t == ei.first && idx == ei.second)
{
oes.erase(oes.begin() + i);
found = true;
break;
}
oes.erase(iter_o);
found = true;
}
for (size_t i = 0; i < ies.size(); ++i)
auto iter_i = std::find_if(ies.begin(), ies.end(),
[&] (const auto& ei) -> bool
{return s == ei.first && idx == ei.second;});
if (iter_i != ies.end())
{
const auto& ei = ies[i];
if (s == ei.first && idx == ei.second)
{
ies.erase(ies.begin() + i);
found = true;
break;
}
oes.erase(iter_i);
found = true;
}
}
else // O(1)
......
......@@ -145,7 +145,7 @@ public:
: _filtered_property(&filtered_property), _invert(invert) {}
template <class Descriptor>
__attribute__((always_inline)) inline bool operator() (Descriptor&& d) const
inline bool operator() (Descriptor&& d) const
{
// ignore if masked
......
......@@ -74,7 +74,7 @@ struct in_degreeS
in_degreeS() {}
template <class Graph, class Vertex>
inline __attribute__((always_inline))
inline
size_t operator()(const Vertex& v, const Graph &g) const
{
return in_degreeS::operator()(v, g, detail::no_weightS());
......@@ -82,7 +82,7 @@ struct in_degreeS
template <class Graph, class Vertex, class Weight>
typename detail::get_weight_type<Weight>::type
inline __attribute__((always_inline))
inline
operator()(const Vertex& v, const Graph &g, Weight&& weight) const
{
typedef typename is_convertible
......@@ -92,7 +92,7 @@ struct in_degreeS
}
template <class Graph, class Vertex>
inline __attribute__((always_inline))
inline
size_t get_in_degree(const Vertex& v, const Graph &g, std::true_type,
detail::no_weightS)
const
......@@ -114,7 +114,7 @@ struct in_degreeS
}
template <class Graph, class Vertex, class Weight>
inline __attribute__((always_inline))
inline
size_t get_in_degree(const Vertex&, const Graph &, std::false_type, Weight&&)
const
{
......@@ -129,14 +129,14 @@ struct out_degreeS
out_degreeS() {}
template <class Graph, class Vertex>
inline __attribute__((always_inline))
inline
size_t operator()(const Vertex& v, const Graph &g) const
{
return out_degreeS::operator()(v, g, detail::no_weightS());
}
template <class Graph, class Vertex, class Weight>
inline __attribute__((always_inline))
inline
typename detail::get_weight_type<Weight>::type
operator()(const Vertex& v, const Graph &g, Weight&& weight) const
{
......@@ -156,7 +156,7 @@ struct out_degreeS
}
template <class Graph, class Vertex>
inline __attribute__((always_inline))
inline
size_t get_out_degree(const Vertex& v, const Graph &g,
detail::no_weightS)
const
......@@ -171,14 +171,14 @@ struct total_degreeS
total_degreeS() {}
template <class Graph, class Vertex>
inline __attribute__((always_inline))
inline
size_t operator()(const Vertex& v, const Graph &g) const
{
return total_degreeS::operator()(v, g, detail::no_weightS());
}
template <class Graph, class Vertex, class Weight>
inline __attribute__((always_inline))
inline
typename detail::get_weight_type<Weight>::type
operator()(const Vertex& v, const Graph &g, Weight&& weight) const
{
......@@ -189,7 +189,7 @@ struct total_degreeS
}
template <class Graph, class Vertex, class Weight>
inline __attribute__((always_inline))
inline
typename detail::get_weight_type<Weight>::type
get_total_degree(const Vertex& v, const Graph &g, std::true_type,
Weight& weight) const
......@@ -198,7 +198,7 @@ struct total_degreeS
}
template <class Graph, class Vertex, class Weight>
inline __attribute__((always_inline))
inline
typename detail::get_weight_type<Weight>::type
get_total_degree(const Vertex& v, const Graph &g, std::false_type,
Weight& weight)
......@@ -218,7 +218,7 @@ struct scalarS
scalarS(PropertyMap pmap): _pmap(pmap) {}
template <class Descriptor, class Graph>
inline __attribute__((always_inline))
inline
typename boost::property_traits<PropertyMap>::value_type
operator()(const Descriptor& d, const Graph &) const
{
......@@ -290,7 +290,7 @@ struct get_in_edges
typedef typename boost::graph_traits<Graph>::vertex_descriptor
vertex_descriptor;
typedef typename boost::graph_traits<Graph>::in_edge_iterator type;
inline __attribute__((always_inline))
inline
static std::pair<type,type> get_edges(vertex_descriptor v,
const Graph& g)
{
......@@ -308,7 +308,7 @@ struct get_in_edges<Graph,std::false_type>
typedef typename boost::graph_traits<Graph>::vertex_descriptor
vertex_descriptor;
typedef typename boost::graph_traits<Graph>::out_edge_iterator type;
inline __attribute__((always_inline))
inline
static std::pair<type,type> get_edges(vertex_descriptor,
const Graph&)
{
......@@ -330,7 +330,7 @@ struct in_edge_iteratorS
typedef typename boost::graph_traits<Graph>::vertex_descriptor
vertex_descriptor;
inline __attribute__((always_inline))
inline
static std::pair<type,type> get_edges(vertex_descriptor v,
const Graph& g)
{
......@@ -346,7 +346,7 @@ struct out_edge_iteratorS
typedef typename boost::graph_traits<Graph>::vertex_descriptor
vertex_descriptor;
inline __attribute__((always_inline))
inline
static std::pair<type,type> get_edges(vertex_descriptor v,
const Graph& g)
{
......@@ -366,7 +366,7 @@ struct get_all_edges
vertex_descriptor;
typedef typename boost::graph_traits<boost::UndirectedAdaptor<Graph> >::out_edge_iterator
type;
inline __attribute__((always_inline))
inline
static std::pair<type,type> get_edges(vertex_descriptor v,
const Graph& g)
{
......@@ -407,7 +407,7 @@ struct all_edges_iteratorS
typedef typename boost::graph_traits<Graph>::vertex_descriptor
vertex_descriptor;
inline __attribute__((always_inline))
inline
static std::pair<type,type> get_edges(vertex_descriptor v,
const Graph& g)
{
......@@ -440,7 +440,7 @@ struct in_or_out_edge_iteratorS
typedef typename boost::graph_traits<Graph>::vertex_descriptor
vertex_descriptor;
inline __attribute__((always_inline))
inline
static std::pair<type,type> get_edges(vertex_descriptor v,
const Graph& g)
{
......@@ -462,14 +462,14 @@ private:
};
template <class Iter>
inline __attribute__((always_inline))
inline
IterRange<Iter> mk_range(const std::pair<Iter, Iter>& range)
{
return IterRange<Iter>(range);
}
template <class Graph>
inline __attribute__((always_inline))
inline
IterRange<typename boost::graph_traits<Graph>::vertex_iterator>
vertices_range(const Graph& g)
{
......@@ -477,7 +477,7 @@ vertices_range(const Graph& g)
}
template <class Graph>
inline __attribute__((always_inline))
inline
IterRange<typename boost::graph_traits<Graph>::edge_iterator>
edges_range(const Graph& g)
{
......@@ -485,7 +485,7 @@ edges_range(const Graph& g)
}
template <class Graph>
inline __attribute__((always_inline))
inline
IterRange<typename boost::graph_traits<Graph>::adjacency_iterator>
adjacent_vertices_range(typename boost::graph_traits<Graph>::vertex_descriptor v,
const Graph& g)
......@@ -494,7 +494,7 @@ adjacent_vertices_range(typename boost::graph_traits<Graph>::vertex_descriptor v
}
template <class Graph>
inline __attribute__((always_inline))
inline
IterRange<typename out_edge_iteratorS<Graph>::type>
out_edges_range(typename out_edge_iteratorS<Graph>::vertex_descriptor v,
const Graph& g)
......@@ -503,7 +503,7 @@ out_edges_range(typename out_edge_iteratorS<Graph>::vertex_descriptor v,
}
template <class Graph>
inline __attribute__((always_inline))
inline
IterRange<typename in_edge_iteratorS<Graph>::type>
in_edges_range(typename in_edge_iteratorS<Graph>::vertex_descriptor v,
const Graph& g)
......@@ -512,7 +512,7 @@ in_edges_range(typename in_edge_iteratorS<Graph>::vertex_descriptor v,
}
template <class Graph>
inline __attribute__((always_inline))
inline
IterRange<typename all_edges_iteratorS<Graph>::type>
all_edges_range(typename all_edges_iteratorS<Graph>::vertex_descriptor v,
const Graph& g)
......@@ -521,7 +521,7 @@ all_edges_range(typename all_edges_iteratorS<Graph>::vertex_descriptor v,
}
template <class Graph>
inline __attribute__((always_inline))
inline
IterRange<typename in_or_out_edge_iteratorS<Graph>::type>
in_or_out_edges_range(typename in_or_out_edge_iteratorS<Graph>::vertex_descriptor v,
const Graph& g)
......
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