Refactor graph writing code in contractor

This commit is contained in:
Patrick Niklaus
2017-04-02 23:02:57 +00:00
committed by Patrick Niklaus
parent 90c194fc81
commit ef3fcdc6e6
11 changed files with 172 additions and 221 deletions
+13
View File
@@ -239,6 +239,19 @@ class DeallocatingVector
bucket_list.emplace_back(new ElementT[ELEMENTS_PER_BLOCK]);
}
DeallocatingVector(DeallocatingVector &&other)
{
bucket_list = std::move(other.bucket_list);
current_size = std::move(other.current_size);
}
DeallocatingVector& operator=(DeallocatingVector &&other)
{
bucket_list = std::move(other.bucket_list);
current_size = std::move(other.current_size);
return *this;
}
~DeallocatingVector() { clear(); }
friend void swap<>(DeallocatingVector<ElementT, ELEMENTS_PER_BLOCK> &lhs,
+5 -2
View File
@@ -9,6 +9,8 @@ namespace osrm
{
namespace util
{
namespace serialization
{
template <typename EdgeDataT, storage::Ownership Ownership>
inline void read(storage::io::FileReader &reader,
@@ -20,7 +22,7 @@ inline void read(storage::io::FileReader &reader,
template <typename EdgeDataT, storage::Ownership Ownership>
inline void write(storage::io::FileWriter &writer,
StaticGraph<EdgeDataT, Ownership> &graph)
const StaticGraph<EdgeDataT, Ownership> &graph)
{
writer.SerializeVector(graph.node_array);
writer.SerializeVector(graph.edge_array);
@@ -43,7 +45,7 @@ inline void read(storage::io::FileReader &reader,
template <typename EdgeDataT>
inline void write(storage::io::FileWriter &writer,
DynamicGraph<EdgeDataT> &graph)
const DynamicGraph<EdgeDataT> &graph)
{
writer.SerializeVector(graph.node_array);
writer.WriteElementCount64(graph.number_of_edges);
@@ -53,6 +55,7 @@ inline void write(storage::io::FileWriter &writer,
}
}
}
}
}
+3 -3
View File
@@ -139,7 +139,7 @@ class StaticGraph
StaticGraph() {}
template <typename ContainerT> StaticGraph(const int nodes, const ContainerT &edges)
template <typename ContainerT> StaticGraph(const std::uint32_t nodes, const ContainerT &edges)
{
BOOST_ASSERT(std::is_sorted(const_cast<ContainerT &>(edges).begin(),
const_cast<ContainerT &>(edges).end()));
@@ -258,7 +258,7 @@ class StaticGraph
protected:
template <typename IterT>
void InitializeFromSortedEdgeRange(const unsigned nodes, IterT begin, IterT end)
void InitializeFromSortedEdgeRange(const std::uint32_t nodes, IterT begin, IterT end)
{
number_of_nodes = nodes;
number_of_edges = static_cast<EdgeIterator>(std::distance(begin, end));
@@ -272,7 +272,7 @@ class StaticGraph
unsigned offset = std::distance(begin, iter);
node_array.push_back(NodeArrayEntry{offset});
}
BOOST_ASSERT(iter == end);
BOOST_ASSERT_MSG(iter == end, ("Still " + std::to_string(std::distance(iter, end)) + " edges left.").c_str());
BOOST_ASSERT(node_array.size() == number_of_nodes + 1);
edge_array.resize(number_of_edges);