occurrences method
Returns a new Map with the number of occurrences of each element.
Implementation
Map<T, int> occurrences() {
Map<T, int> map = {};
for (T e in this) {
if (map.containsKey(e)) {
map[e] = map[e]! + 1;
} else {
map[e] = 1;
}
}
return map;
}