replace boost integer range

This commit is contained in:
Dennis Luxen 2014-08-05 17:19:09 +02:00
parent 284e671163
commit d4bf02c882
13 changed files with 61 additions and 60 deletions

View File

@ -34,6 +34,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "../DataStructures/ImportEdge.h"
#include "../DataStructures/QueryNode.h"
#include "../DataStructures/Percent.h"
#include "../DataStructures/Range.h"
#include "../DataStructures/Restriction.h"
#include "../DataStructures/TurnInstructions.h"
@ -46,7 +47,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <boost/assert.hpp>
#include <boost/filesystem.hpp>
#include <boost/range/irange.hpp>
#include <tbb/parallel_sort.h>
@ -239,7 +239,7 @@ class TarjanSCC
int index = 0;
const NodeID last_node = m_node_based_graph->GetNumberOfNodes();
std::vector<bool> processing_node_before_recursion(m_node_based_graph->GetNumberOfNodes(), true);
for(const NodeID node : boost::irange(0u, last_node))
for(const NodeID node : osrm::irange(0u, last_node))
{
if (SPECIAL_NODEID == components_index[node])
{
@ -344,7 +344,7 @@ class TarjanSCC
uint64_t total_network_distance = 0;
p.reinit(m_node_based_graph->GetNumberOfNodes());
// const NodeID last_u_node = m_node_based_graph->GetNumberOfNodes();
for (const NodeID source : boost::irange(0u, last_node))
for (const NodeID source : osrm::irange(0u, last_node))
{
p.printIncrement();
for (const auto current_edge : m_node_based_graph->GetAdjacentEdgeRange(source))

View File

@ -33,6 +33,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "../DataStructures/DynamicGraph.h"
#include "../DataStructures/Percent.h"
#include "../DataStructures/QueryEdge.h"
#include "../DataStructures/Range.h"
#include "../DataStructures/XORFastHash.h"
#include "../DataStructures/XORFastHashStorage.h"
#include "../Util/SimpleLogger.h"
@ -41,7 +42,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "../typedefs.h"
#include <boost/assert.hpp>
#include <boost/range/irange.hpp>
#include <stxxl/vector>
@ -360,7 +360,7 @@ class Contractor
// build forward and backward renumbering map and remap ids in remaining_nodes and
// Priorities.
for (const auto new_node_id : boost::irange(0u, (unsigned)remaining_nodes.size()))
for (const auto new_node_id : osrm::irange<std::size_t>(0, remaining_nodes.size()))
{
// create renumbering maps in both directions
orig_node_id_to_new_id_map[new_node_id] = remaining_nodes[new_node_id].id;
@ -370,7 +370,7 @@ class Contractor
remaining_nodes[new_node_id].id = new_node_id;
}
// walk over all nodes
for (const auto i : boost::irange(0u, (unsigned)contractor_graph->GetNumberOfNodes()))
for (const auto i : osrm::irange<std::size_t>(0, contractor_graph->GetNumberOfNodes()))
{
const NodeID source = i;
for (auto current_edge : contractor_graph->GetAdjacentEdgeRange(source))
@ -560,7 +560,7 @@ class Contractor
if (contractor_graph->GetNumberOfNodes())
{
Edge new_edge;
for (const auto node : boost::irange(0u, number_of_nodes))
for (const auto node : osrm::irange(0u, number_of_nodes))
{
p.printStatus(node);
for (auto edge : contractor_graph->GetAdjacentEdgeRange(node))
@ -848,7 +848,7 @@ class Contractor
std::sort(neighbours.begin(), neighbours.end());
neighbours.resize(std::unique(neighbours.begin(), neighbours.end()) - neighbours.begin());
for (const auto i : boost::irange(0u, (unsigned)neighbours.size()))
for (const auto i : osrm::irange<std::size_t>(0, neighbours.size()))
{
contractor_graph->DeleteEdgesTo(neighbours[i], node);
}

View File

@ -28,13 +28,13 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "EdgeBasedGraphFactory.h"
#include "../Algorithms/BFSComponentExplorer.h"
#include "../DataStructures/Percent.h"
#include "../DataStructures/Range.h"
#include "../Util/ComputeAngle.h"
#include "../Util/LuaUtil.h"
#include "../Util/SimpleLogger.h"
#include "../Util/TimingUtil.h"
#include <boost/assert.hpp>
#include <boost/range.hpp>
#include <fstream>
#include <limits>
@ -134,7 +134,7 @@ EdgeBasedGraphFactory::InsertEdgeBasedNode(const NodeID u, const NodeID v, const
// TODO: move to lambda function with C++11
int temp_sum = 0;
for (const auto i : boost::irange(0u, geometry_size))
for (const auto i : osrm::irange(0u, geometry_size))
{
forward_dist_prefix_sum[i] = temp_sum;
temp_sum += forward_geometry[i].second;
@ -143,7 +143,7 @@ EdgeBasedGraphFactory::InsertEdgeBasedNode(const NodeID u, const NodeID v, const
}
temp_sum = 0;
for (const auto i : boost::irange(0u, geometry_size))
for (const auto i : osrm::irange(0u, geometry_size))
{
temp_sum += reverse_geometry[reverse_geometry.size() - 1 - i].second;
reverse_dist_prefix_sum[i] = reverse_data.distance - temp_sum;
@ -162,7 +162,7 @@ EdgeBasedGraphFactory::InsertEdgeBasedNode(const NodeID u, const NodeID v, const
}
// traverse arrays from start and end respectively
for (const auto i : boost::irange(0u, geometry_size))
for (const auto i : osrm::irange(0u, geometry_size))
{
BOOST_ASSERT(current_edge_source_coordinate_id ==
reverse_geometry[geometry_size - 1 - i].first);
@ -287,7 +287,7 @@ void EdgeBasedGraphFactory::CompressGeometry()
Percent p(original_number_of_nodes);
unsigned removed_node_count = 0;
for (const NodeID v : boost::irange(0u, original_number_of_nodes))
for (const NodeID v : osrm::irange(0u, original_number_of_nodes))
{
p.printStatus(v);
@ -418,7 +418,7 @@ void EdgeBasedGraphFactory::CompressGeometry()
unsigned new_node_count = 0;
unsigned new_edge_count = 0;
for(const auto i : boost::irange(0u, m_node_based_graph->GetNumberOfNodes()))
for(const auto i : osrm::irange(0u, m_node_based_graph->GetNumberOfNodes()))
{
if (m_node_based_graph->GetOutDegree(i) > 0)
{

View File

@ -32,6 +32,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "../Algorithms/IteratorBasedCRC32.h"
#include "../DataStructures/BinaryHeap.h"
#include "../DataStructures/DeallocatingVector.h"
#include "../DataStructures/Range.h"
#include "../DataStructures/StaticRTree.h"
#include "../DataStructures/RestrictionMap.h"
@ -45,7 +46,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <boost/filesystem/fstream.hpp>
#include <boost/program_options.hpp>
#include <boost/range.hpp>
#include <tbb/task_scheduler_init.h>
#include <tbb/parallel_sort.h>
@ -232,7 +232,7 @@ int Prepare::Process(int argc, char *argv[])
StaticGraph<EdgeData>::EdgeIterator last_edge = edge;
// initializing 'first_edge'-field of nodes:
for (const auto node : boost::irange(0u, max_used_node_id))
for (const auto node : osrm::irange(0u, max_used_node_id))
{
last_edge = edge;
while ((edge < contracted_edge_count) && (contracted_edge_list[edge].source == node))
@ -243,7 +243,7 @@ int Prepare::Process(int argc, char *argv[])
position += edge - last_edge; // remove
}
for (const auto sentinel_counter : boost::irange(max_used_node_id, (unsigned)node_array.size()))
for (const auto sentinel_counter : osrm::irange<unsigned>(max_used_node_id, node_array.size()))
{
// sentinel element, guarded against underflow
node_array[sentinel_counter].first_edge = contracted_edge_count;
@ -271,7 +271,7 @@ int Prepare::Process(int argc, char *argv[])
int number_of_used_edges = 0;
StaticGraph<EdgeData>::EdgeArrayEntry current_edge;
for (const auto edge : boost::irange(0u, (unsigned)contracted_edge_list.size()))
for (const auto edge : osrm::irange<std::size_t>(0, contracted_edge_list.size()))
{
// no eigen loops
BOOST_ASSERT(contracted_edge_list[edge].source != contracted_edge_list[edge].target);

View File

@ -28,8 +28,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef DEALLOCATINGVECTOR_H_
#define DEALLOCATINGVECTOR_H_
#include "Range.h"
#include <boost/iterator/iterator_facade.hpp>
#include <boost/range/irange.hpp>
#include <utility>
#include <vector>
@ -235,7 +236,7 @@ class DeallocatingVector
else
{ // down-size
const std::size_t number_of_necessary_buckets = 1 + (new_size / ELEMENTS_PER_BLOCK);
for (auto bucket_index : boost::irange(number_of_necessary_buckets, bucket_list.size()))
for (const auto bucket_index : osrm::irange(number_of_necessary_buckets, bucket_list.size()))
{
if (nullptr != bucket_list[bucket_index])
{

View File

@ -28,10 +28,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef DYNAMICGRAPH_H
#define DYNAMICGRAPH_H
#include "../DataStructures/DeallocatingVector.h"
#include "DeallocatingVector.h"
#include "Range.h"
#include <boost/assert.hpp>
#include <boost/range/irange.hpp>
#include <cstdint>
@ -43,10 +43,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
template <typename EdgeDataT> class DynamicGraph
{
public:
typedef decltype(boost::irange(0u, 0u)) EdgeRange;
typedef EdgeDataT EdgeData;
typedef unsigned NodeIterator;
typedef unsigned EdgeIterator;
typedef osrm::range<EdgeIterator> EdgeRange;
class InputEdge
{
@ -88,7 +88,7 @@ template <typename EdgeDataT> class DynamicGraph
node_list.resize(number_of_nodes + 1);
EdgeIterator edge = 0;
EdgeIterator position = 0;
for (const auto node : boost::irange(0u, number_of_nodes))
for (const auto node : osrm::irange(0u, number_of_nodes))
{
EdgeIterator lastEdge = edge;
while (edge < number_of_edges && graph[edge].source == node)
@ -103,9 +103,9 @@ template <typename EdgeDataT> class DynamicGraph
edge_list.reserve((std::size_t)edge_list.size() * 1.1);
edge_list.resize(position);
edge = 0;
for (const auto node : boost::irange(0u, number_of_nodes))
for (const auto node : osrm::irange(0u, number_of_nodes))
{
for (const auto i : boost::irange(node_list[node].firstEdge,
for (const auto i : osrm::irange(node_list[node].firstEdge,
node_list[node].firstEdge + node_list[node].edges))
{
edge_list[i].target = graph[edge].target;
@ -126,7 +126,7 @@ template <typename EdgeDataT> class DynamicGraph
unsigned GetDirectedOutDegree(const NodeIterator n) const
{
unsigned degree = 0;
for (const auto edge : boost::irange(BeginEdges(n), EndEdges(n)))
for (const auto edge : osrm::irange(BeginEdges(n), EndEdges(n)))
{
if (GetEdgeData(edge).forward)
{
@ -156,7 +156,7 @@ template <typename EdgeDataT> class DynamicGraph
EdgeRange GetAdjacentEdgeRange(const NodeIterator node) const
{
return boost::irange(BeginEdges(node), EndEdges(node));
return osrm::irange(BeginEdges(node), EndEdges(node));
}
NodeIterator InsertNode()
@ -190,12 +190,12 @@ template <typename EdgeDataT> class DynamicGraph
edge_list.reserve(requiredCapacity * 1.1);
}
edge_list.resize(edge_list.size() + newSize);
for (const auto i : boost::irange(0u, node.edges))
for (const auto i : osrm::irange(0u, node.edges))
{
edge_list[newFirstEdge + i] = edge_list[node.firstEdge + i];
makeDummy(node.firstEdge + i);
}
for (const auto i : boost::irange(node.edges + 1, newSize))
for (const auto i : osrm::irange(node.edges + 1, newSize))
{
makeDummy(newFirstEdge + i);
}
@ -250,7 +250,7 @@ template <typename EdgeDataT> class DynamicGraph
// searches for a specific edge
EdgeIterator FindEdge(const NodeIterator from, const NodeIterator to) const
{
for (const auto i : boost::irange(BeginEdges(from), EndEdges(from)))
for (const auto i : osrm::irange(BeginEdges(from), EndEdges(from)))
{
if (to == edge_list[i].target)
{

View File

@ -48,6 +48,8 @@ template <typename Integer> class range
// Iterable functions
const range &begin() const { return *this; }
const range &end() const { return *this; }
Integer front() const { return iter; }
Integer back() const { return last-1; }
// Iterator functions
bool operator!=(const range &) const { return iter < last; }

View File

@ -1,11 +1,10 @@
#ifndef __RANGE_TABLE_H__
#define __RANGE_TABLE_H__
#include "Range.h"
#include "SharedMemoryFactory.h"
#include "SharedMemoryVectorWrapper.h"
#include <boost/range/irange.hpp>
#include <fstream>
#include <vector>
#include <array>
@ -40,7 +39,7 @@ public:
typedef std::array<unsigned char, BLOCK_SIZE> BlockT;
typedef typename ShM<BlockT, USE_SHARED_MEMORY>::vector BlockContainerT;
typedef typename ShM<unsigned, USE_SHARED_MEMORY>::vector OffsetContainerT;
typedef decltype(boost::irange(0u,0u)) RangeT;
typedef osrm::range<unsigned> RangeT;
friend std::ostream& operator<< <>(std::ostream &out, const RangeTable &table);
friend std::istream& operator>> <>(std::istream &in, RangeTable &table);
@ -167,7 +166,7 @@ public:
BOOST_ASSERT(begin_idx < sum_lengths && end_idx <= sum_lengths);
BOOST_ASSERT(begin_idx <= end_idx);
return boost::irange(begin_idx, end_idx);
return osrm::irange(begin_idx, end_idx);
}
private:

View File

@ -28,13 +28,13 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef STATIC_GRAPH_H
#define STATIC_GRAPH_H
#include "../DataStructures/Percent.h"
#include "../DataStructures/SharedMemoryVectorWrapper.h"
#include "Percent.h"
#include "Range.h"
#include "SharedMemoryVectorWrapper.h"
#include "../Util/SimpleLogger.h"
#include "../typedefs.h"
#include <boost/assert.hpp>
#include <boost/range/irange.hpp>
#include <tbb/parallel_sort.h>
@ -46,10 +46,11 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
template <typename EdgeDataT, bool UseSharedMemory = false> class StaticGraph
{
public:
typedef decltype(boost::irange(0u,0u)) EdgeRange;
typedef NodeID NodeIterator;
typedef NodeID EdgeIterator;
typedef EdgeDataT EdgeData;
typedef osrm::range<EdgeIterator> EdgeRange;
class InputEdge
{
public:
@ -83,7 +84,7 @@ template <typename EdgeDataT, bool UseSharedMemory = false> class StaticGraph
EdgeRange GetAdjacentEdgeRange(const NodeID node) const
{
return boost::irange(BeginEdges(node), EndEdges(node));
return osrm::irange(BeginEdges(node), EndEdges(node));
}
StaticGraph(const int nodes, std::vector<InputEdge> &graph)
@ -94,7 +95,7 @@ template <typename EdgeDataT, bool UseSharedMemory = false> class StaticGraph
node_array.resize(number_of_nodes + 1);
EdgeIterator edge = 0;
EdgeIterator position = 0;
for (const auto node : boost::irange(0u, number_of_nodes+1))
for (const auto node : osrm::irange(0u, number_of_nodes+1))
{
EdgeIterator last_edge = edge;
while (edge < number_of_edges && graph[edge].source == node)
@ -106,7 +107,7 @@ template <typename EdgeDataT, bool UseSharedMemory = false> class StaticGraph
}
edge_array.resize(position); //(edge)
edge = 0;
for (const auto node : boost::irange(0u, number_of_nodes))
for (const auto node : osrm::irange(0u, number_of_nodes))
{
EdgeIterator e = node_array[node + 1].first_edge;
for (EdgeIterator i = node_array[node].first_edge; i != e; ++i)

View File

@ -33,14 +33,13 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "../Algorithms/ObjectToBase64.h"
#include "../Algorithms/ExtractRouteNames.h"
#include "../DataStructures/JSONContainer.h"
#include "../DataStructures/Range.h"
#include "../DataStructures/SegmentInformation.h"
#include "../DataStructures/TurnInstructions.h"
#include "../Util/Azimuth.h"
#include "../Util/StringUtil.h"
#include "../Util/TimingUtil.h"
#include <boost/range/irange.hpp>
#include <algorithm>
template <class DataFacadeT> class JSONDescriptor : public BaseDescriptor<DataFacadeT>
@ -120,7 +119,7 @@ template <class DataFacadeT> class JSONDescriptor : public BaseDescriptor<DataFa
json_result.values["status_message"] = "Found route between points";
// for each unpacked segment add the leg to the description
for (const auto i : boost::irange((std::size_t)0, raw_route.unpacked_path_segments.size()))
for (const auto i : osrm::irange<std::size_t>(0, raw_route.unpacked_path_segments.size()))
{
#ifndef NDEBUG
const int added_segments =
@ -278,7 +277,7 @@ template <class DataFacadeT> class JSONDescriptor : public BaseDescriptor<DataFa
json_hint_object.values["checksum"] = raw_route.check_sum;
JSON::Array json_location_hint_array;
std::string hint;
for (const auto i : boost::irange((std::size_t)0, raw_route.segment_end_coordinates.size()))
for (const auto i : osrm::irange<std::size_t>(0, raw_route.segment_end_coordinates.size()))
{
EncodeObjectToBase64(raw_route.segment_end_coordinates[i].source_phantom, hint);
json_location_hint_array.values.push_back(hint);

View File

@ -29,10 +29,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define ALTERNATIVE_PATH_ROUTING_H
#include "BasicRoutingInterface.h"
#include "../DataStructures/Range.h"
#include "../DataStructures/SearchEngineData.h"
#include <boost/assert.hpp>
#include <boost/range/irange.hpp>
#include <unordered_map>
#include <unordered_set>
@ -456,7 +456,7 @@ template <class DataFacadeT> class AlternativeRouting : private BasicRoutingInte
// First partially unpack s-->v until paths deviate, note length of common path.
const int64_t s_v_min_path_size =
std::min(packed_s_v_path.size(), packed_shortest_path.size()) - 1;
for (const int64_t current_node : boost::irange((int64_t)0, s_v_min_path_size))
for (const int64_t current_node : osrm::irange<int64_t>(0, s_v_min_path_size))
{
if (packed_s_v_path[current_node] == packed_shortest_path[current_node] &&
packed_s_v_path[current_node + 1] == packed_shortest_path[current_node + 1])

View File

@ -29,9 +29,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define SHORTEST_PATH_ROUTING_H
#include <boost/assert.hpp>
#include <boost/range/irange.hpp>
#include "BasicRoutingInterface.h"
#include "../DataStructures/Range.h"
#include "../DataStructures/SearchEngineData.h"
#include "../typedefs.h"
@ -57,8 +57,8 @@ template <class DataFacadeT> class ShortestPathRouting : public BasicRoutingInte
int distance2 = 0;
bool search_from_1st_node = true;
bool search_from_2nd_node = true;
NodeID middle1 = UINT_MAX;
NodeID middle2 = UINT_MAX;
NodeID middle1 = SPECIAL_NODEID;
NodeID middle2 = SPECIAL_NODEID;
std::vector<std::vector<NodeID>> packed_legs1(phantom_nodes_vector.size());
std::vector<std::vector<NodeID>> packed_legs2(phantom_nodes_vector.size());
@ -82,11 +82,11 @@ template <class DataFacadeT> class ShortestPathRouting : public BasicRoutingInte
forward_heap2.Clear();
reverse_heap1.Clear();
reverse_heap2.Clear();
int local_upper_bound1 = INT_MAX;
int local_upper_bound2 = INT_MAX;
int local_upper_bound1 = INVALID_EDGE_WEIGHT;
int local_upper_bound2 = INVALID_EDGE_WEIGHT;
middle1 = UINT_MAX;
middle2 = UINT_MAX;
middle1 = SPECIAL_NODEID;
middle2 = SPECIAL_NODEID;
const bool allow_u_turn = current_leg > 0 && uturn_indicators.size() > current_leg && uturn_indicators[current_leg-1];
EdgeWeight min_edge_offset = 0;
@ -200,7 +200,7 @@ template <class DataFacadeT> class ShortestPathRouting : public BasicRoutingInte
}
// Was at most one of the two paths not found?
BOOST_ASSERT_MSG((INT_MAX != distance1 || INT_MAX != distance2), "no path found");
BOOST_ASSERT_MSG((INVALID_EDGE_WEIGHT != distance1 || INVALID_EDGE_WEIGHT != distance2), "no path found");
// Unpack paths if they exist
std::vector<NodeID> temporary_packed_leg1;
@ -309,7 +309,7 @@ template <class DataFacadeT> class ShortestPathRouting : public BasicRoutingInte
}
raw_route_data.unpacked_path_segments.resize(packed_legs1.size());
for (const std::size_t index : boost::irange((std::size_t)0, packed_legs1.size()))
for (const std::size_t index : osrm::irange<std::size_t>(0, packed_legs1.size()))
{
BOOST_ASSERT(!phantom_nodes_vector.empty());
BOOST_ASSERT(packed_legs1.size() == raw_route_data.unpacked_path_segments.size());

View File

@ -33,18 +33,17 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "../../DataStructures/EdgeBasedNode.h"
#include "../../DataStructures/ImportNode.h"
#include "../../DataStructures/PhantomNodes.h"
#include "../../DataStructures/Range.h"
#include "../../DataStructures/TurnInstructions.h"
#include "../../Util/OSRMException.h"
#include "../../Util/StringUtil.h"
#include "../../typedefs.h"
#include <boost/range/irange.hpp>
#include <osrm/Coordinate.h>
#include <string>
typedef decltype(boost::irange(0u,0u)) EdgeRange;
typedef osrm::range<EdgeID> EdgeRange;
template <class EdgeDataT> class BaseDataFacade
{