removeId method

bool removeId(
  1. Object? id
)

Remove the first entry whose id equals id. Swap-last, O(N) in the id lookup.

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 * codeSize, (i + 1) * codeSize, _codes, (n - 1) * codeSize);
        _ids[i] = _ids[n - 1];
      }
      _ids.removeLast();
      return true;
    }
  }
  return false;
}