Sha256: 301e55fab276ee3f95bee73fa7d1a80afa7dfe85eee1d8c1b571d5438ca9f74c

Contents?: true

Size: 1.38 KB

Versions: 36

Compression:

Stored size: 1.38 KB

Contents

use crate::{LinearGroupBy, LinearGroupByMut};

/// An iterator that will return non-overlapping groups of equal elements
/// in the slice using *linear/sequential search*.
///
/// It will give two contiguous elements to the [`PartialEq::eq`] function
/// therefore the slice must not be necessarily sorted.
///
/// [`PartialEq::eq`]: https://doc.rust-lang.org/std/cmp/trait.PartialEq.html#tymethod.eq
pub struct LinearGroup<'a, T: 'a>(LinearGroupBy<'a, T, fn(&T, &T) -> bool>);

impl<'a, T: 'a> LinearGroup<'a, T>
where T: PartialEq,
{
    pub fn new(slice: &'a [T]) -> LinearGroup<'a, T> {
        LinearGroup(LinearGroupBy::new(slice, PartialEq::eq))
    }
}

group_by_wrapped!{ struct LinearGroup, &'a [T] }

/// An iterator that will return non-overlapping *mutable* groups of equal elements
/// in the slice using *linear/sequential search*.
///
/// It will give two contiguous elements to the [`PartialEq::eq`] function
/// therefore the slice must not be necessarily sorted.
///
/// [`PartialEq::eq`]: https://doc.rust-lang.org/std/cmp/trait.PartialEq.html#tymethod.eq
pub struct LinearGroupMut<'a, T: 'a>(LinearGroupByMut<'a, T, fn(&T, &T) -> bool>);

impl<'a, T: 'a> LinearGroupMut<'a, T>
where T: PartialEq,
{
    pub fn new(slice: &'a mut [T]) -> LinearGroupMut<'a, T> {
        LinearGroupMut(LinearGroupByMut::new(slice, PartialEq::eq))
    }
}

group_by_wrapped!{ struct LinearGroupMut, &'a mut [T] }

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
wasmtime-27.0.0 ./ext/cargo-vendor/slice-group-by-0.3.1/src/linear_group/linear_group.rs
wasmtime-26.0.0 ./ext/cargo-vendor/slice-group-by-0.3.1/src/linear_group/linear_group.rs
wasmtime-25.0.2 ./ext/cargo-vendor/slice-group-by-0.3.1/src/linear_group/linear_group.rs
wasmtime-25.0.1 ./ext/cargo-vendor/slice-group-by-0.3.1/src/linear_group/linear_group.rs
wasmtime-25.0.0 ./ext/cargo-vendor/slice-group-by-0.3.1/src/linear_group/linear_group.rs
wasmtime-24.0.0 ./ext/cargo-vendor/slice-group-by-0.3.1/src/linear_group/linear_group.rs
wasmtime-23.0.2 ./ext/cargo-vendor/slice-group-by-0.3.1/src/linear_group/linear_group.rs
wasmtime-22.0.0 ./ext/cargo-vendor/slice-group-by-0.3.1/src/linear_group/linear_group.rs
wasmtime-21.0.1 ./ext/cargo-vendor/slice-group-by-0.3.1/src/linear_group/linear_group.rs
wasmtime-20.0.2 ./ext/cargo-vendor/slice-group-by-0.3.1/src/linear_group/linear_group.rs
wasmtime-20.0.0 ./ext/cargo-vendor/slice-group-by-0.3.1/src/linear_group/linear_group.rs
wasmtime-18.0.3 ./ext/cargo-vendor/slice-group-by-0.3.1/src/linear_group/linear_group.rs
wasmtime-17.0.1 ./ext/cargo-vendor/slice-group-by-0.3.1/src/linear_group/linear_group.rs
wasmtime-17.0.0 ./ext/cargo-vendor/slice-group-by-0.3.1/src/linear_group/linear_group.rs
wasmtime-16.0.0 ./ext/cargo-vendor/slice-group-by-0.3.1/src/linear_group/linear_group.rs
wasmtime-15.0.1 ./ext/cargo-vendor/slice-group-by-0.3.1/src/linear_group/linear_group.rs
wasmtime-15.0.0 ./ext/cargo-vendor/slice-group-by-0.3.1/src/linear_group/linear_group.rs
wasmtime-14.0.4 ./ext/cargo-vendor/slice-group-by-0.3.1/src/linear_group/linear_group.rs
wasmtime-14.0.3 ./ext/cargo-vendor/slice-group-by-0.3.1/src/linear_group/linear_group.rs
wasmtime-14.0.1 ./ext/cargo-vendor/slice-group-by-0.3.1/src/linear_group/linear_group.rs