[][src]Trait flatk::SplitAt

pub trait SplitAt where
    Self: Sized
{ fn split_at(self, mid: usize) -> (Self, Self); }

A helper trait to split a set into two sets at a given index. This trait is used to implement iteration over ChunkedViews.

Required methods

fn split_at(self, mid: usize) -> (Self, Self)

Split self into two sets at the given midpoint. This function is analogous to <[T]>::split_at.

Loading content...

Implementations on Foreign Types

impl<T> SplitAt for Range<T> where
    T: From<usize>, 
[src]

impl<'a, '_, T> SplitAt for &'_ mut [T][src]

impl<'a, '_, T> SplitAt for &'_ [T][src]

impl<S, T> SplitAt for (S, T) where
    S: SplitAt,
    T: SplitAt
[src]

impl<T> SplitAt for Vec<T>[src]

Loading content...

Implementors

impl<'_, V> SplitAt for SubsetView<'_, V> where
    V: Set + SplitAt
[src]

This impl enables Chunked Subsets

fn split_at(self, mid: usize) -> (Self, Self)[src]

Split this subset into two at the given index mid.

Example

use flatk::*;
let v = vec![1,2,3,4,5];
let indices = vec![0,2,4];
let subset = Subset::from_unique_ordered_indices(indices.as_slice(), v.as_slice());
let (l, r) = subset.split_at(1);
let mut iter_l = l.iter();
assert_eq!(Some(&1), iter_l.next());
assert_eq!(None, iter_l.next());
let mut iter_r = r.iter();
assert_eq!(Some(&3), iter_r.next());
assert_eq!(Some(&5), iter_r.next());
assert_eq!(None, iter_r.next());

impl<S, O> SplitAt for Chunked<S, O> where
    S: SplitAt + Set,
    O: SplitOffsetsAt
[src]

impl<S, T, I> SplitAt for Sparse<S, T, I> where
    S: Set + SplitAt,
    T: Set + Clone,
    I: SplitAt
[src]

impl<S: SplitAt + Set> SplitAt for ChunkedN<S>[src]

fn split_at(self, mid: usize) -> (Self, Self)[src]

Split the current set into two distinct sets at the given index mid.

Example

use flatk::*;
let s = ChunkedN::from_flat_with_stride(vec![0,1,2,3], 2);
let (l, r) = s.split_at(1);
assert_eq!(l, ChunkedN::from_flat_with_stride(vec![0,1], 2));
assert_eq!(r, ChunkedN::from_flat_with_stride(vec![2,3], 2));

impl<S: SplitAt + Set, N: Copy + Unsigned> SplitAt for UniChunked<S, U<N>>[src]

fn split_at(self, mid: usize) -> (Self, Self)[src]

Split the current set into two distinct sets at the given index mid.

Example

use flatk::*;
let s = Chunked2::from_flat(vec![0,1,2,3]);
let (l, r) = s.split_at(1);
assert_eq!(l, Chunked2::from_flat(vec![0,1]));
assert_eq!(r, Chunked2::from_flat(vec![2,3]));

impl<V, I> SplitAt for Select<V, I> where
    V: Set + Clone,
    I: SplitAt
[src]

fn split_at(self, mid: usize) -> (Self, Self)[src]

Split this selection into two at the given index mid.

Example

use flatk::*;
let v = vec![1,2,3,4,5];
let indices = vec![3,2,0,4,2];
let selection = Select::new(indices.as_slice(), v.as_slice());
let (l, r) = selection.split_at(2);
let mut iter_l = l.iter();
assert_eq!(Some((3, &4)), iter_l.next());
assert_eq!(Some((2, &3)), iter_l.next());
assert_eq!(None, iter_l.next());
let mut iter_r = r.iter();
assert_eq!(Some((0, &1)), iter_r.next());
assert_eq!(Some((4, &5)), iter_r.next());
assert_eq!(Some((2, &3)), iter_r.next()); // Note that 3 is shared between l and r
assert_eq!(None, iter_r.next());
Loading content...