removeWhereKeyIn method

void removeWhereKeyIn(
  1. Set<TKey> keys
)

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 cache decrements fire only for dropped nids whose key is still live at call time (and only when _suppress is false). Released nids are assumed to have already been cleaned up in the per-nid caches by the path that released them (e.g. the controller's _releaseNid).

Implementation

void removeWhereKeyIn(Set<TKey> keys) {
  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)) {
      if (!_suppress) bumpFromSelf(nid, -1);
      continue;
    }
    _orderNids[writeIdx++] = nid;
  }
  if (writeIdx != _len) {
    _onMutated();
  }
  _len = writeIdx;
}