method iter.groupBy
Groups by key in order of first appearance (a barrier: the whole input is pulled at the first pull).
Example:
fn main() io {
for g in ["apple", "avocado", "banana"].iter().groupBy(s => s.slice(0, 1)) {
print("{g.key}: {g.items}")
}
}Вывод
a: ["apple", "avocado"] b: ["banana"]
pub(api) move fn groupBy<K, effect F>(key: fn(T) -> K F escaping) -> iter<Group<K, T>> FСложность. O(n); the whole input is pulled at the first pull.
С версии. 1.0.0-beta
Параметры
| Имя | Тип |
|---|---|
key | fn(T) -> K F escaping |
Возвращает
Эффекты
не объявлены (чистая, пока тело не говорит иное)
Определено в: std/core/iter.oxl:462