static bool SlowRekey(IntSet* s) { IntSet tmp; for (auto iter = s->iter(); !iter.done(); iter.next()) { if (NewKeyFunction::shouldBeRemoved(iter.get())) { continue; } uint32_t hi = NewKeyFunction::rekey(iter.get()); if (tmp.has(hi)) { return false; } if (!tmp.putNew(hi)) { return false; } } s->clear(); for (auto iter = tmp.iter(); !iter.done(); iter.next()) { if (!s->putNew(iter.get())) { return false; } } return true; }
static bool SetsAreEqual(IntSet& am, IntSet& bm) { bool equal = true; if (am.count() != bm.count()) { equal = false; fprintf(stderr, "A.count() == %u and B.count() == %u\n", am.count(), bm.count()); } for (auto iter = am.iter(); !iter.done(); iter.next()) { if (!bm.has(iter.get())) { equal = false; fprintf(stderr, "B does not have %x which is in A\n", iter.get()); } } for (auto iter = bm.iter(); !iter.done(); iter.next()) { if (!am.has(iter.get())) { equal = false; fprintf(stderr, "A does not have %x which is in B\n", iter.get()); } } return equal; }