pub trait UsizeGroupBy<V> {
    // Required method
    fn usize_group_by(self, index: impl FnMut(&V) -> usize) -> Vec<Vec<V>>;
}
Expand description

イテレータのグルーピング。

See also

GroupBy

Required Methods§

source

fn usize_group_by(self, index: impl FnMut(&V) -> usize) -> Vec<Vec<V>>

Examples
use nekolib::traits::UsizeGroupBy;

let a = vec![1, 4, 3, -5, -6, 0, 2, -2, 3];
let g = a.iter().copied().usize_group_by(|&ai: &i32| ai.rem_euclid(3) as usize);

assert_eq!(g.len(), 3);
assert_eq!(g[0], [3, -6, 0, 3]);
assert_eq!(g[1], [1, 4, -5, -2]);
assert_eq!(g[2], [2]);

Implementors§

source§

impl<V, I: Iterator<Item = V>> UsizeGroupBy<V> for I