From 858245db7d9c25a75be2fa3040198d24033ff0e8 Mon Sep 17 00:00:00 2001 From: Dennis Luxen Date: Tue, 10 Feb 2015 11:35:58 +0100 Subject: [PATCH] fix warning: implicit signed/unsigned warning --- algorithms/tiny_components.hpp | 4 ++-- data_structures/binary_heap.hpp | 19 +++++++------------ data_structures/deallocating_vector.hpp | 6 +++++- data_structures/dynamic_graph.hpp | 2 +- data_structures/node_based_graph.hpp | 14 +++++++------- data_structures/xor_fast_hash.hpp | 12 ++++++------ 6 files changed, 28 insertions(+), 29 deletions(-) diff --git a/algorithms/tiny_components.hpp b/algorithms/tiny_components.hpp index 5354fc785..b595ac427 100644 --- a/algorithms/tiny_components.hpp +++ b/algorithms/tiny_components.hpp @@ -102,7 +102,7 @@ template class TarjanSCC std::stack tarjan_stack; std::vector 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 processing_node_before_recursion(m_node_based_graph->GetNumberOfNodes(), true); @@ -226,7 +226,7 @@ template 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 { diff --git a/data_structures/binary_heap.hpp b/data_structures/binary_heap.hpp index 4522460a2..3a2796d7c 100644 --- a/data_structures/binary_heap.hpp +++ b/data_structures/binary_heap.hpp @@ -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 class ArrayStorage { public: - explicit ArrayStorage(size_t size) : positions(size, 0) - { - } + explicit ArrayStorage(size_t size) : positions(size, 0) {} - ~ArrayStorage() { } + ~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 class MapStorage } return std::numeric_limits::max(); } + private: std::map 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); } diff --git a/data_structures/deallocating_vector.hpp b/data_structures/deallocating_vector.hpp index 5ea2a81ce..968528f3c 100644 --- a/data_structures/deallocating_vector.hpp +++ b/data_structures/deallocating_vector.hpp @@ -32,12 +32,16 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include +#include #include #include template struct DeallocatingVectorIteratorState { - DeallocatingVectorIteratorState() : index(-1), bucket_list(nullptr) {} + DeallocatingVectorIteratorState() + : index(std::numeric_limits::max()), bucket_list(nullptr) + { + } explicit DeallocatingVectorIteratorState(const DeallocatingVectorIteratorState &r) : index(r.index), bucket_list(r.bucket_list) { diff --git a/data_structures/dynamic_graph.hpp b/data_structures/dynamic_graph.hpp index 4a666c136..abaa05717 100644 --- a/data_structures/dynamic_graph.hpp +++ b/data_structures/dynamic_graph.hpp @@ -90,7 +90,7 @@ template class DynamicGraph template DynamicGraph(const NodeIterator nodes, const ContainerT &graph) { number_of_nodes = nodes; - number_of_edges = (EdgeIterator)graph.size(); + number_of_edges = static_cast(graph.size()); node_list.reserve(number_of_nodes + 1); node_list.resize(number_of_nodes + 1); EdgeIterator edge = 0; diff --git a/data_structures/node_based_graph.hpp b/data_structures/node_based_graph.hpp index 49dba2c08..82eb59bd5 100644 --- a/data_structures/node_based_graph.hpp +++ b/data_structures/node_based_graph.hpp @@ -112,7 +112,7 @@ NodeBasedDynamicGraphFromImportEdges(int number_of_nodes, std::vector(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::max()) + if (static_cast(forward_edge.data.distance) != std::numeric_limits::max()) { forward_edge.data.backward = true; edges_list[edge_count++] = forward_edge; @@ -179,11 +179,11 @@ NodeBasedDynamicGraphFromImportEdges(int number_of_nodes, std::vector::max()) + if (static_cast(forward_edge.data.distance) != std::numeric_limits::max()) { edges_list[edge_count++] = forward_edge; } - if ((int)reverse_edge.data.distance != std::numeric_limits::max()) + if (static_cast(reverse_edge.data.distance) != std::numeric_limits::max()) { edges_list[edge_count++] = reverse_edge; } @@ -252,18 +252,18 @@ SimpleNodeBasedDynamicGraphFromEdges(int number_of_nodes, std::vector(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(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(reverse_edge.data.capacity) != INVALID_EDGE_WEIGHT) { edges_list[edge_count++] = reverse_edge; } diff --git a/data_structures/xor_fast_hash.hpp b/data_structures/xor_fast_hash.hpp index 1f6dc29bb..9e952193d 100644 --- a/data_structures/xor_fast_hash.hpp +++ b/data_structures/xor_fast_hash.hpp @@ -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(i); + table2[i] = static_cast(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(i); + table2[i] = static_cast(i); + table3[i] = static_cast(i); + table4[i] = static_cast(i); } std::random_shuffle(table1.begin(), table1.end()); std::random_shuffle(table2.begin(), table2.end());