removeWhereKeyIn method
Compacts the order by dropping every entry whose key is in keys, or
whose nid has been released. Preserves the relative order of kept
entries.
Per-nid removal callbacks fire only for dropped nids whose key is
still live at call time. Released nids are assumed to have already
been cleaned up in per-nid aggregate caches by the path that
released them (e.g. _releaseNid).
Implementation
void removeWhereKeyIn(Set<TKey> keys) {
final cb = _onNidRemoved;
int writeIdx = 0;
for (int readIdx = 0; readIdx < _len; readIdx++) {
final nid = _orderNids[readIdx];
final key = _nids.keyOf(nid);
if (key == null) {
continue;
}
if (keys.contains(key)) {
cb?.call(nid);
continue;
}
_orderNids[writeIdx++] = nid;
}
if (writeIdx != _len) {
_onMutated();
}
_len = writeIdx;
}