pairUpIndexes method

List<(int, int)> pairUpIndexes(
  1. List<T> other
)

Returns a list of pairs of indexes, where each pair represents the index of an element in the original list and the index of the same element in the provided other list. If an element in the original list is not found in the other list, its index will be represented as -1 in the pair.

Implementation

List<(int, int)> pairUpIndexes(List<T> other) {
  var l = toList();
  final r = <(int, int)>[];
  for (var i = 0; i < l.length; i++) {
    r.add((i, other.indexOf(l[i])));
  }
  for (var j = 0; j < other.length; j++) {
    final index1 = l.indexOf(other[j]);
    if (index1 == -1) {
      r.add((-1, j));
    }
  }

  return r;
}