Use std::ranges::subrange instead of boost::iterator_range

This commit is contained in:
Siarhei Fedartsou
2024-07-14 15:58:02 +02:00
parent 2faaeb7756
commit 8a31f2f5e3
18 changed files with 66 additions and 145 deletions
@@ -5,8 +5,6 @@
#include "restriction_graph.hpp"
#include "util/typedefs.hpp"
#include <boost/range/adaptor/filtered.hpp>
#include <unordered_map>
#include <utility>
#include <vector>
+18 -20
View File
@@ -7,11 +7,9 @@
#include "storage/shared_memory_ownership.hpp"
#include "storage/tar_fwd.hpp"
#include <boost/range/adaptor/reversed.hpp>
#include <boost/range/iterator_range.hpp>
#include <filesystem>
#include <iostream>
#include <ranges>
#include <string>
#include <unordered_map>
#include <vector>
@@ -79,12 +77,12 @@ template <storage::Ownership Ownership> class SegmentDataContainerImpl
const auto begin = nodes.begin() + index[id];
const auto end = nodes.begin() + index[id + 1];
return boost::make_iterator_range(begin, end);
return std::ranges::subrange(begin, end);
}
auto GetReverseGeometry(const DirectionalGeometryID id)
{
return boost::adaptors::reverse(GetForwardGeometry(id));
return GetForwardGeometry(id) | std::views::reverse;
}
auto GetForwardDurations(const DirectionalGeometryID id)
@@ -92,7 +90,7 @@ template <storage::Ownership Ownership> class SegmentDataContainerImpl
const auto begin = fwd_durations.begin() + index[id] + 1;
const auto end = fwd_durations.begin() + index[id + 1];
return boost::make_iterator_range(begin, end);
return std::ranges::subrange(begin, end);
}
auto GetReverseDurations(const DirectionalGeometryID id)
@@ -100,7 +98,7 @@ template <storage::Ownership Ownership> class SegmentDataContainerImpl
const auto begin = rev_durations.begin() + index[id];
const auto end = rev_durations.begin() + index[id + 1] - 1;
return boost::adaptors::reverse(boost::make_iterator_range(begin, end));
return std::ranges::subrange(begin, end) | std::views::reverse;
}
auto GetForwardWeights(const DirectionalGeometryID id)
@@ -108,7 +106,7 @@ template <storage::Ownership Ownership> class SegmentDataContainerImpl
const auto begin = fwd_weights.begin() + index[id] + 1;
const auto end = fwd_weights.begin() + index[id + 1];
return boost::make_iterator_range(begin, end);
return std::ranges::subrange(begin, end);
}
auto GetReverseWeights(const DirectionalGeometryID id)
@@ -116,7 +114,7 @@ template <storage::Ownership Ownership> class SegmentDataContainerImpl
const auto begin = rev_weights.begin() + index[id];
const auto end = rev_weights.begin() + index[id + 1] - 1;
return boost::adaptors::reverse(boost::make_iterator_range(begin, end));
return std::ranges::subrange(begin, end) | std::views::reverse;
}
auto GetForwardDatasources(const DirectionalGeometryID id)
@@ -124,7 +122,7 @@ template <storage::Ownership Ownership> class SegmentDataContainerImpl
const auto begin = fwd_datasources.begin() + index[id] + 1;
const auto end = fwd_datasources.begin() + index[id + 1];
return boost::make_iterator_range(begin, end);
return std::ranges::subrange(begin, end);
}
auto GetReverseDatasources(const DirectionalGeometryID id)
@@ -132,7 +130,7 @@ template <storage::Ownership Ownership> class SegmentDataContainerImpl
const auto begin = rev_datasources.begin() + index[id];
const auto end = rev_datasources.begin() + index[id + 1] - 1;
return boost::adaptors::reverse(boost::make_iterator_range(begin, end));
return std::ranges::subrange(begin, end) | std::views::reverse;
}
auto GetForwardGeometry(const DirectionalGeometryID id) const
@@ -140,12 +138,12 @@ template <storage::Ownership Ownership> class SegmentDataContainerImpl
const auto begin = nodes.cbegin() + index[id];
const auto end = nodes.cbegin() + index[id + 1];
return boost::make_iterator_range(begin, end);
return std::ranges::subrange(begin, end);
}
auto GetReverseGeometry(const DirectionalGeometryID id) const
{
return boost::adaptors::reverse(GetForwardGeometry(id));
return GetForwardGeometry(id) | std::views::reverse;
}
auto GetForwardDurations(const DirectionalGeometryID id) const
@@ -153,7 +151,7 @@ template <storage::Ownership Ownership> class SegmentDataContainerImpl
const auto begin = fwd_durations.cbegin() + index[id] + 1;
const auto end = fwd_durations.cbegin() + index[id + 1];
return boost::make_iterator_range(begin, end);
return std::ranges::subrange(begin, end);
}
auto GetReverseDurations(const DirectionalGeometryID id) const
@@ -161,7 +159,7 @@ template <storage::Ownership Ownership> class SegmentDataContainerImpl
const auto begin = rev_durations.cbegin() + index[id];
const auto end = rev_durations.cbegin() + index[id + 1] - 1;
return boost::adaptors::reverse(boost::make_iterator_range(begin, end));
return std::ranges::subrange(begin, end) | std::views::reverse;
}
auto GetForwardWeights(const DirectionalGeometryID id) const
@@ -169,7 +167,7 @@ template <storage::Ownership Ownership> class SegmentDataContainerImpl
const auto begin = fwd_weights.cbegin() + index[id] + 1;
const auto end = fwd_weights.cbegin() + index[id + 1];
return boost::make_iterator_range(begin, end);
return std::ranges::subrange(begin, end);
}
auto GetReverseWeights(const DirectionalGeometryID id) const
@@ -177,7 +175,7 @@ template <storage::Ownership Ownership> class SegmentDataContainerImpl
const auto begin = rev_weights.cbegin() + index[id];
const auto end = rev_weights.cbegin() + index[id + 1] - 1;
return boost::adaptors::reverse(boost::make_iterator_range(begin, end));
return std::ranges::subrange(begin, end) | std::views::reverse;
}
auto GetForwardDatasources(const DirectionalGeometryID id) const
@@ -185,7 +183,7 @@ template <storage::Ownership Ownership> class SegmentDataContainerImpl
const auto begin = fwd_datasources.cbegin() + index[id] + 1;
const auto end = fwd_datasources.cbegin() + index[id + 1];
return boost::make_iterator_range(begin, end);
return std::ranges::subrange(begin, end);
}
auto GetReverseDatasources(const DirectionalGeometryID id) const
@@ -193,7 +191,7 @@ template <storage::Ownership Ownership> class SegmentDataContainerImpl
const auto begin = rev_datasources.cbegin() + index[id];
const auto end = rev_datasources.cbegin() + index[id + 1] - 1;
return boost::adaptors::reverse(boost::make_iterator_range(begin, end));
return std::ranges::subrange(begin, end) | std::views::reverse;
}
auto GetNumberOfGeometries() const { return index.size() - 1; }