getValuesByIndexes<V> method

List<(D, V)> getValuesByIndexes<V>(
  1. Iterable<int> indexes,
  2. List<V> values
)

Returns (ID, value) pairs for the given indexes.

values must be aligned with this collection's internal ordering.

Implementation

List<(D, V)> getValuesByIndexes<V>(Iterable<int> indexes, List<V> values) {
  if (values.length < length) {
    return indexes
        .map((i) {
          var id = _ids[i];
          if (i < values.length) {
            return (id, values[i]);
          } else {
            return null;
          }
        })
        .nonNulls
        .toList();
  }

  return indexes.map((i) {
    var id = _ids[i];
    return (id, values[i]);
  }).toList();
}