diff --git a/src/test/heap.cpp b/src/test/heap.cpp index 39353af76..08891ccaa 100644 --- a/src/test/heap.cpp +++ b/src/test/heap.cpp @@ -19,20 +19,19 @@ Revision History: #include #include "util/util.h" #include "util/heap.h" -#include "util/hashtable.h" #include "util/trace.h" +#include "util/uint_set.h" struct lt_proc { bool operator()(int v1, int v2) const { return v1 < v2; } }; typedef heap int_heap; struct int_hash_proc { unsigned operator()(int v) const { return v * 17; }}; -typedef int_hashtable > int_set; #define N 10000 static random_gen heap_rand(1); static void tst1() { int_heap h(N); - int_set t; + uint_set t; for (int i = 0; i < N * 3; i++) { int val = heap_rand() % N; if (!h.contains(val)) { @@ -41,14 +40,15 @@ static void tst1() { t.insert(val); } else { + if (!t.contains(val)) { + for (int v : t) std::cout << v << "\n"; + } ENSURE(t.contains(val)); } } ENSURE(h.check_invariant()); - int_set::iterator it = t.begin(); - int_set::iterator end = t.end(); - for (; it != end; ++it) { - ENSURE(h.contains(*it)); + for (int v : t) { + ENSURE(h.contains(v)); } while (!h.empty()) { int m1 = h.min_value(); @@ -84,6 +84,8 @@ static void dump_heap(const int_heap2 & h, std::ostream & out) { static void tst2() { int_heap2 h(N); for (int i = 0; i < N * 10; i++) { + + if (i % 1 == 0) std::cout << "i: " << i << std::endl; if (i % 1000 == 0) std::cout << "i: " << i << std::endl; int cmd = heap_rand() % 10; if (cmd <= 3) { @@ -134,6 +136,7 @@ void tst_heap() { enable_trace("heap"); unsigned i = 0; while (i < 3) { + IF_VERBOSE(1, verbose_stream() << "test\n";); heap_rand.set_seed(i++); tst1(); init_values(); diff --git a/src/util/top_sort.h b/src/util/top_sort.h index d017d162b..5f7db9c3e 100644 --- a/src/util/top_sort.h +++ b/src/util/top_sort.h @@ -42,7 +42,7 @@ class top_sort { unsigned p_id = 0; if (m_dfs_num.find(f, p_id)) { if (!m_partition_id.contains(f)) { - while (!m_stack_P.empty() && m_partition_id[m_stack_P.back()] > p_id) { + while (!m_stack_P.empty() && m_partition_id.contains(m_stack_P.back()) && m_partition_id[m_stack_P.back()] > p_id) { m_stack_P.pop_back(); } }