dedupByKey<K> method
void
dedupByKey<K>(
- K f(
- T
Removes all but the first of consecutive elements in the vector for which the given predicate returns true. If the vector is sorted, this removes all duplicates.
Implementation
void dedupByKey<K>(K Function(T) f) {
late K last;
bool first = true;
removeWhere((element) {
if (first) {
last = f(element);
first = false;
return false;
}
if (f(element) == last) {
return true;
}
last = f(element);
return false;
});
}