removeId method

bool removeId(
  1. Object? id
)

Remove the first entry whose id equals id via swap-last. O(N).

Implementation

bool removeId(Object? id) {
  for (var i = 0; i < _ids.length; i++) {
    if (_ids[i] == id) {
      final n = _ids.length;
      if (i != n - 1) {
        _codes.setRange(i * m, (i + 1) * m, _codes, (n - 1) * m);
        _ids[i] = _ids[n - 1];
      }
      _ids.removeLast();
      return true;
    }
  }
  return false;
}