From 0da041477b669502c3e271499590ab1e12c3450c Mon Sep 17 00:00:00 2001 From: Patrick Niklaus Date: Wed, 5 Apr 2017 10:23:34 +0000 Subject: [PATCH] Adjust generation counted array for PR comments --- include/util/binary_heap.hpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/include/util/binary_heap.hpp b/include/util/binary_heap.hpp index dca3eb973..3d88a9138 100644 --- a/include/util/binary_heap.hpp +++ b/include/util/binary_heap.hpp @@ -20,7 +20,7 @@ template class GenerationArrayStorage { using GenerationCounter = std::uint16_t; public: - explicit GenerationArrayStorage(std::size_t size) : positions(size, 0), generation(0), generations(size, 0) {} + explicit GenerationArrayStorage(std::size_t size) : positions(size, 0), generation(1), generations(size, 0) {} Key &operator[](NodeID node) { generation[node] = generation; @@ -37,10 +37,11 @@ template class GenerationArrayStorage void Clear() { generation++; - if (generation == std::numeric_limits::max()) + // if generation overflows we end up at 0 again and need to clear the vector + if (generation == 0) { + generation = 1; std::fill(generations.begin(), generations.end(), 0); - std::fill(positions.begin(), positions.end(), 0); } }