static bool MapsAreEqual(IntMap& am, IntMap& 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 (IntMap::Range r = am.all(); !r.empty(); r.popFront()) { if (!bm.has(r.front().key())) { equal = false; fprintf(stderr, "B does not have %x which is in A\n", r.front().key()); } } for (IntMap::Range r = bm.all(); !r.empty(); r.popFront()) { if (!am.has(r.front().key())) { equal = false; fprintf(stderr, "A does not have %x which is in B\n", r.front().key()); } } return equal; }
static bool SlowRekey(IntMap* m) { IntMap tmp; if (!tmp.init()) return false; for (IntMap::Range r = m->all(); !r.empty(); r.popFront()) { if (NewKeyFunction::shouldBeRemoved(r.front().key())) continue; uint32_t hi = NewKeyFunction::rekey(r.front().key()); if (tmp.has(hi)) return false; if (!tmp.putNew(hi, r.front().value())) return false; } m->clear(); for (IntMap::Range r = tmp.all(); !r.empty(); r.popFront()) { if (!m->putNew(r.front().key(), r.front().value())) return false; } return true; }