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 SlowRekey(IntSet *s) { IntSet tmp; tmp.init(); for (IntSet::Range r = s->all(); !r.empty(); r.popFront()) { if (NewKeyFunction::shouldBeRemoved(r.front())) continue; uint32_t hi = NewKeyFunction::rekey(r.front()); if (tmp.has(hi)) return false; tmp.putNew(hi); } s->clear(); for (IntSet::Range r = tmp.all(); !r.empty(); r.popFront()) { s->putNew(r.front()); } return true; }