associate<K, V> method
Returns a Map containing key-value pairs provided by transform function
applied to elements of this collection.
If any of two pairs would have the same key the last one gets added to the map.
Implementation
Map<K, V> associate<K, V>(
(K, V) Function(int index, E element) transform,
) {
final map = <K, V>{};
final it = iterator;
for (var i = 0; it.moveNext(); i++) {
final (key, value) = transform(i, it.current);
map[key] = value;
}
return map;
}