fix warning: implicit signed/unsigned warning

This commit is contained in:
Dennis Luxen 2015-02-10 11:35:58 +01:00
parent 09bea2ad5b
commit 858245db7d
6 changed files with 28 additions and 29 deletions

View File

@ -102,7 +102,7 @@ template <typename GraphT> class TarjanSCC
std::stack<NodeID> tarjan_stack;
std::vector<TarjanNode> tarjan_node_list(m_node_based_graph->GetNumberOfNodes());
unsigned component_index = 0, size_of_current_component = 0;
int index = 0;
unsigned index = 0;
const NodeID last_node = m_node_based_graph->GetNumberOfNodes();
std::vector<bool> processing_node_before_recursion(m_node_based_graph->GetNumberOfNodes(),
true);
@ -226,7 +226,7 @@ template <typename GraphT> class TarjanSCC
std::size_t get_number_of_components() const { return component_size_vector.size(); }
unsigned get_size_one_count() const { return size_one_counter; }
std::size_t get_size_one_count() const { return size_one_counter; }
unsigned get_component_size(const NodeID node) const
{

View File

@ -1,6 +1,6 @@
/*
Copyright (c) 2014, Project OSRM, Dennis Luxen, others
Copyright (c) 2015, Project OSRM, Dennis Luxen, others
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
@ -40,18 +40,13 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
template <typename NodeID, typename Key> class ArrayStorage
{
public:
explicit ArrayStorage(size_t size) : positions(size, 0)
{
}
explicit ArrayStorage(size_t size) : positions(size, 0) {}
~ArrayStorage() {}
Key &operator[](NodeID node) { return positions[node]; }
Key peek_index(const NodeID node) const
{
return positions[node];
}
Key peek_index(const NodeID node) const { return positions[node]; }
void Clear() {}
@ -77,6 +72,7 @@ template <typename NodeID, typename Key> class MapStorage
}
return std::numeric_limits<Key>::max();
}
private:
std::map<NodeID, Key> nodes;
};
@ -262,8 +258,7 @@ class BinaryHeap
while (nextKey < heap_size)
{
const Key nextKeyOther = nextKey + 1;
if ((nextKeyOther < heap_size) &&
(heap[nextKey].weight > heap[nextKeyOther].weight))
if ((nextKeyOther < heap_size) && (heap[nextKey].weight > heap[nextKeyOther].weight))
{
nextKey = nextKeyOther;
}
@ -302,7 +297,7 @@ class BinaryHeap
void CheckHeap()
{
#ifndef NDEBUG
for (Key i = 2; i < (Key)heap.size(); ++i)
for (std::size_t i = 2; i < heap.size(); ++i)
{
BOOST_ASSERT(heap[i].weight >= heap[i >> 1].weight);
}

View File

@ -32,12 +32,16 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <boost/iterator/iterator_facade.hpp>
#include <limits>
#include <utility>
#include <vector>
template <typename ElementT> struct DeallocatingVectorIteratorState
{
DeallocatingVectorIteratorState() : index(-1), bucket_list(nullptr) {}
DeallocatingVectorIteratorState()
: index(std::numeric_limits<std::size_t>::max()), bucket_list(nullptr)
{
}
explicit DeallocatingVectorIteratorState(const DeallocatingVectorIteratorState &r)
: index(r.index), bucket_list(r.bucket_list)
{

View File

@ -90,7 +90,7 @@ template <typename EdgeDataT> class DynamicGraph
template <class ContainerT> DynamicGraph(const NodeIterator nodes, const ContainerT &graph)
{
number_of_nodes = nodes;
number_of_edges = (EdgeIterator)graph.size();
number_of_edges = static_cast<EdgeIterator>(graph.size());
node_list.reserve(number_of_nodes + 1);
node_list.resize(number_of_nodes + 1);
EdgeIterator edge = 0;

View File

@ -112,7 +112,7 @@ NodeBasedDynamicGraphFromImportEdges(int number_of_nodes, std::vector<ImportEdge
continue;
}
edge.data.distance = (std::max)((int)import_edge.weight, 1);
edge.data.distance = (std::max)(static_cast<int>(import_edge.weight), 1);
BOOST_ASSERT(edge.data.distance > 0);
edge.data.shortcut = false;
edge.data.roundabout = import_edge.roundabout;
@ -171,7 +171,7 @@ NodeBasedDynamicGraphFromImportEdges(int number_of_nodes, std::vector<ImportEdge
// merge edges (s,t) and (t,s) into bidirectional edge
if (forward_edge.data.distance == reverse_edge.data.distance)
{
if ((int)forward_edge.data.distance != std::numeric_limits<int>::max())
if (static_cast<int>(forward_edge.data.distance) != std::numeric_limits<int>::max())
{
forward_edge.data.backward = true;
edges_list[edge_count++] = forward_edge;
@ -179,11 +179,11 @@ NodeBasedDynamicGraphFromImportEdges(int number_of_nodes, std::vector<ImportEdge
}
else
{ // insert seperate edges
if (((int)forward_edge.data.distance) != std::numeric_limits<int>::max())
if (static_cast<int>(forward_edge.data.distance) != std::numeric_limits<int>::max())
{
edges_list[edge_count++] = forward_edge;
}
if ((int)reverse_edge.data.distance != std::numeric_limits<int>::max())
if (static_cast<int>(reverse_edge.data.distance) != std::numeric_limits<int>::max())
{
edges_list[edge_count++] = reverse_edge;
}
@ -252,18 +252,18 @@ SimpleNodeBasedDynamicGraphFromEdges(int number_of_nodes, std::vector<SimpleEdge
// merge edges (s,t) and (t,s) into bidirectional edge
if (forward_edge.data.capacity == reverse_edge.data.capacity)
{
if ((int)forward_edge.data.capacity != INVALID_EDGE_WEIGHT)
if (static_cast<int>(forward_edge.data.capacity) != INVALID_EDGE_WEIGHT)
{
edges_list[edge_count++] = forward_edge;
}
}
else
{ // insert seperate edges
if (((int)forward_edge.data.capacity) != INVALID_EDGE_WEIGHT)
if (static_cast<int>(forward_edge.data.capacity) != INVALID_EDGE_WEIGHT)
{
edges_list[edge_count++] = forward_edge;
}
if ((int)reverse_edge.data.capacity != INVALID_EDGE_WEIGHT)
if (static_cast<int>(reverse_edge.data.capacity) != INVALID_EDGE_WEIGHT)
{
edges_list[edge_count++] = reverse_edge;
}

View File

@ -61,8 +61,8 @@ class XORFastHash
table2.resize(2 << 16);
for (unsigned i = 0; i < (2 << 16); ++i)
{
table1[i] = i;
table2[i] = i;
table1[i] = static_cast<unsigned short>(i);
table2[i] = static_cast<unsigned short>(i);
}
std::random_shuffle(table1.begin(), table1.end());
std::random_shuffle(table2.begin(), table2.end());
@ -92,10 +92,10 @@ class XORMiniHash
table4.resize(1 << 8);
for (unsigned i = 0; i < (1 << 8); ++i)
{
table1[i] = i;
table2[i] = i;
table3[i] = i;
table4[i] = i;
table1[i] = static_cast<unsigned char>(i);
table2[i] = static_cast<unsigned char>(i);
table3[i] = static_cast<unsigned char>(i);
table4[i] = static_cast<unsigned char>(i);
}
std::random_shuffle(table1.begin(), table1.end());
std::random_shuffle(table2.begin(), table2.end());