From e81b3fa645d52a9f5d695013cb871eb7dda54944 Mon Sep 17 00:00:00 2001 From: Daniel Lemire Date: Fri, 3 Mar 2017 19:20:26 -0500 Subject: [PATCH] Fixing typo --- include/concise.h | 2 +- tests/unit.cpp | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/include/concise.h b/include/concise.h index bcf269c..7be756b 100644 --- a/include/concise.h +++ b/include/concise.h @@ -987,7 +987,7 @@ class ConciseSetBitForwardIterator { if(word_value != 0) { uint32_t t = word_value & (-word_value); has_value = true; - current_value = word_location * 32 + __builtin_popcount(t - 1); + current_value = word_location * 31 + __builtin_popcount(t - 1); word_value ^= t; } else { has_value = false; diff --git a/tests/unit.cpp b/tests/unit.cpp index f5e2f86..e4b5b76 100644 --- a/tests/unit.cpp +++ b/tests/unit.cpp @@ -174,10 +174,27 @@ template static bool equals(std::set s, ConciseSet c) { if (s.size() != c.size()) return false; + // we go one way for (std::set::iterator i = s.begin(); i != s.end(); i++) { if (!c.contains(*i)) return false; } + // we go both ways + std::set::iterator a = s.begin(); + auto b = c.begin(); + for (; (a != s.end()) && (b != c.end()); a++, b++) { + if (*a != *b) { + return false; + } + } + + // we go another way + for (auto i = c.begin(); i != c.end(); i++) { + if (s.find(*i) == s.end()) { + std::cout << " There is probably an issue with the ConciseSet iterators? " << std::endl; + return false; + } + } return true; }