intersection method

List<(int, D)> intersection(
  1. List<D> ids
)

Returns the intersection between this collection and ids, preserving the order of the input ids.

Each entry is a pair of (index, id) where index refers to this collection's internal ordering.

Implementation

List<(int, D)> intersection(List<D> ids) {
  var l = <(int, D)>[];

  for (var id in ids) {
    var idx = binarySearchIndex(id);
    if (idx >= 0) {
      l.add((idx, id));
    }
  }

  return l;
}