withoutRedundancies<T> function

List<T> withoutRedundancies<T>(
  1. List<T> list
)

Implementation

List<T> withoutRedundancies<T>(List<T> list) {
  var reversedResult = <T>[];
  var used = <T>{}; // "used" is Set<T>()
  for (var x in list.reversed) {
    if (!used.contains(x)) {
      reversedResult.add(x);
      used.add(x);
    }
  }

  return reversedResult.reversed.toList();
}