distinctByComparison method
- bool comparison(
- T,
- T
Removes duplicate elements from a list based on a provided comparison function.
Implementation
Set<T> distinctByComparison(bool Function(T, T) comparison) {
Set<T> uniqueElements = {};
for (T element in this) {
if (!uniqueElements.any((e) => comparison(e, element))) {
uniqueElements.add(element);
}
}
return uniqueElements;
}