[][src]Struct flatk::UniChunked

pub struct UniChunked<S, N> {
    pub data: S,
    pub chunk_size: N,
}

UniChunked Assigns a stride N to the specified collection.

Example

use flatk::*;
let s = Chunked2::from_flat(vec![1,2,3,4,5,6]);
let mut iter = s.iter();
assert_eq!(Some(&[1,2]), iter.next());
assert_eq!(Some(&[3,4]), iter.next());
assert_eq!(Some(&[5,6]), iter.next());
assert_eq!(None, iter.next());

Fields

data: Schunk_size: N

Methods

impl<T, N: Default + Array<T>> UniChunked<Vec<T>, U<N>>[src]

pub fn from_array_vec(data: Vec<N::Array>) -> UniChunked<Vec<T>, U<N>>[src]

Create a UniChunked collection from a Vec of arrays.

Example

use flatk::*;
let v = vec![[1,2,3],[4,5,6],[7,8,9]];
let c = Chunked3::from_array_vec(v);
assert_eq!(c.data(), &vec![1,2,3,4,5,6,7,8,9]);

impl<'a, T, N: Default + Array<T>> UniChunked<&'a [T], U<N>>[src]

pub fn from_array_slice(data: &[N::Array]) -> UniChunked<&[T], U<N>>[src]

Create a UniChunked collection from a slice of arrays.

Example

use flatk::*;
let v = vec![[1,2,3],[4,5,6],[7,8,9]];
let c = Chunked3::from_array_vec(v.clone());
assert_eq!(c.data(), &[1,2,3,4,5,6,7,8,9]);

impl<'a, T, N: Default + Array<T>> UniChunked<&'a mut [T], U<N>>[src]

pub fn from_array_slice_mut(
    data: &'a mut [N::Array]
) -> UniChunked<&'a mut [T], U<N>>
[src]

Create a UniChunked collection from a mutable slice of arrays.

Example

use flatk::*;
let mut v = vec![[1,2,3],[4,5,6],[7,8,9]];
let c = Chunked3::from_array_slice_mut(v.as_mut_slice());
assert_eq!(c.data(), &mut [1,2,3,4,5,6,7,8,9]);

impl<S, N: Copy> UniChunked<S, N>[src]

pub fn view<'a>(&'a self) -> UniChunked<S::Type, N> where
    S: View<'a>, 
[src]

impl<S: Set, N: Array<<S as Set>::Elem>> UniChunked<S, U<N>>[src]

pub fn into_arrays(self) -> S::Output where
    S: ReinterpretAsGrouped<N>, 
[src]

Convert this UniChunked collection into arrays.

Example

use flatk::*;
let mut v = vec![[1,2,3],[4,5,6],[7,8,9]];

// Convert to and from a `Vec` of arrays.
let v_new = Chunked3::from_array_vec(v.clone()).into_arrays();
assert_eq!(v.clone(), v_new);

// Convert to and from an immutable slice of arrays.
let v_new = Chunked3::from_array_slice(v.as_slice()).into_arrays();
assert_eq!(v.as_slice(), v_new);

// Convert to and from a mutable slice of arrays.
let mut v_exp = v.clone();
let v_result = Chunked3::from_array_slice_mut(v.as_mut_slice()).into_arrays();
assert_eq!(v_exp.as_mut_slice(), v_result);

pub fn as_mut_arrays<'a>(
    &'a mut self
) -> <&'a mut S as ReinterpretAsGrouped<N>>::Output where
    &'a mut S: ReinterpretAsGrouped<N>, 
[src]

pub fn as_arrays<'a>(&'a self) -> <&'a S as ReinterpretAsGrouped<N>>::Output where
    &'a S: ReinterpretAsGrouped<N>, 
[src]

impl<S: ChunkSize, N: Dimension> UniChunked<S, N>[src]

pub fn inner_chunk_size(&self) -> usize[src]

impl<S, N> UniChunked<S, N>[src]

pub fn data(&self) -> &S[src]

Get a immutable reference to the underlying data.

Example

use flatk::*;
let v = vec![1,2,3,4,5,6];
let s = Chunked3::from_flat(v.clone());
assert_eq!(&v, s.data());

pub fn data_mut(&mut self) -> &mut S[src]

Get a mutable reference to the underlying data.

Example

use flatk::*;
let mut v = vec![1,2,3,4,5,6];
let mut s = Chunked3::from_flat(v.clone());
v[2] = 100;
s.data_mut()[2] = 100;
assert_eq!(&v, s.data());

impl<S: Default, N: Default> UniChunked<S, U<N>>[src]

pub fn new() -> Self[src]

Create an empty UniChunked collection that groups elements into N sized chunks.

Example

use flatk::*;
let mut s = Chunked3::<Vec<usize>>::new();
assert_eq!(s, Chunked3::from_flat(Vec::new()));
s.push([1,2,3]);
let mut iter = s.iter();
assert_eq!(Some(&[1,2,3]), iter.next());
assert_eq!(None, iter.next());

impl<S: Set, N: Unsigned + Default> UniChunked<S, U<N>>[src]

pub fn from_flat(data: S) -> Self[src]

Create a UniChunked collection that groups the elements of the original set into uniformly sized groups at compile time.

Example

use flatk::*;
let s = Chunked3::from_flat(vec![1,2,3,4,5,6]);
let mut iter = s.iter();
assert_eq!(Some(&[1,2,3]), iter.next());
assert_eq!(Some(&[4,5,6]), iter.next());
assert_eq!(None, iter.next());

impl<S, N> UniChunked<S, N>[src]

pub fn into_inner(self) -> S[src]

Convert this UniChunked collection into its inner representation.

impl<S: Default> UniChunked<S, usize>[src]

pub fn with_stride(n: usize) -> Self[src]

Create an empty UniChunked collection that groups elements into n sized chunks.

Example

use flatk::*;
let mut s = ChunkedN::<Vec<_>>::with_stride(3);
s.push(&[1,2,3][..]);
let mut iter = s.iter();
assert_eq!(Some(&[1,2,3][..]), iter.next());
assert_eq!(None, iter.next());

impl<S: Set> UniChunked<S, usize>[src]

pub fn from_flat_with_stride(data: S, n: usize) -> Self[src]

Create a UniChunked collection that groups the elements of the original set into uniformly sized groups at compile time.

Example

use flatk::*;
let s = ChunkedN::from_flat_with_stride(vec![1,2,3,4,5,6], 3);
let mut iter = s.iter();
assert_eq!(Some(&[1,2,3][..]), iter.next());
assert_eq!(Some(&[4,5,6][..]), iter.next());
assert_eq!(None, iter.next());

impl<S, N> UniChunked<S, N>[src]

pub fn copy_from_flat<T>(&mut self, src: &[T]) where
    T: Copy,
    S: AsMut<[T]>, 
[src]

This function panics if src has doesn't have a length equal to self.len()*N::value().

pub fn clone_from_flat<T>(&mut self, src: &[T]) where
    T: Clone,
    S: AsMut<[T]>, 
[src]

This function panics if src has doesn't have a length equal to self.len()*N::value().

impl<S, N> UniChunked<S, U<N>> where
    S: Set + UniChunkable<N>,
    N: Unsigned
[src]

pub fn copy_from_arrays(&mut self, src: &[N::Array]) where
    N: Array<<S as Set>::Elem>,
    <S as Set>::Elem: Copy,
    S: AsMut<[<S as Set>::Elem]>, 
[src]

This function panics if src has doesn't have a length equal to self.len().

pub fn clone_from_arrays(&mut self, src: &[N::Array]) where
    N: Array<<S as Set>::Elem>,
    <S as Set>::Elem: Clone,
    S: AsMut<[<S as Set>::Elem]>, 
[src]

This function panics if src has doesn't have a length equal to self.len().

impl<T, N: Unsigned + Array<T>> UniChunked<Vec<T>, U<N>>[src]

pub fn reserve(&mut self, new_length: usize)[src]

impl<T> UniChunked<S, usize>[src]

pub fn reserve(&mut self, new_length: usize)[src]

impl<T, N: Unsigned + Array<T>> UniChunked<Vec<T>, U<N>> where
    <N as Array<T>>::Array: Clone
[src]

pub fn resize(&mut self, new_length: usize, default: N::Array) where
    T: PushArrayToVec<N> + Clone
[src]

impl<T> UniChunked<S, usize>[src]

pub fn resize(&mut self, new_length: usize, default: &[T]) where
    T: Clone
[src]

impl<T, N> UniChunked<Vec<T>, U<N>> where
    N: Array<T>,
    T: Clone
[src]

pub fn extend_from_slice(&mut self, slice: &[N::Array])[src]

Extend this chunked Vec from a slice of arrays.

Example

use flatk::*;
let mut s = Chunked2::from_flat(vec![0,1,2,3]);
s.extend_from_slice(&[[4,5], [6,7]]);
assert_eq!(s.data(), &vec![0,1,2,3,4,5,6,7]);

impl<S, N> UniChunked<S, U<N>> where
    N: Unsigned
[src]

pub fn iter<'a>(&'a self) -> <S::Type as IntoStaticChunkIterator<N>>::IterType where
    S: View<'a>,
    <S as View<'a>>::Type: IntoStaticChunkIterator<N>, 
[src]

Produce an iterator over borrowed grouped elements of the UniChunked.

Examples

The following is a simple test for iterating over a uniformly organized Vec.

use flatk::*;
let mut s = UniChunked::<_, U2>::from_flat(vec![1,2,3,4]);
let mut iter = s.iter();
assert_eq!(Some(&[1,2]), iter.next());
assert_eq!(Some(&[3,4]), iter.next());
assert_eq!(None, iter.next());

A more complex example consists of data organized as a nested UniChunked.

use flatk::*;
let s0 = UniChunked::<_, U2>::from_flat(vec![1,2, 3,4, 5,6, 7,8, 9,10, 11,12]);
let s1 = UniChunked::<_, U3>::from_flat(s0);
let mut iter1 = s1.iter();
let mut s0 = iter1.next().unwrap();
let mut iter0 = s0.iter();
assert_eq!(Some(&[1,2]), iter0.next());
assert_eq!(Some(&[3,4]), iter0.next());
assert_eq!(Some(&[5,6]), iter0.next());
assert_eq!(None, iter0.next());
let s0 = iter1.next().unwrap();
let mut iter0 = s0.iter();
assert_eq!(Some(&[7,8]), iter0.next());
assert_eq!(Some(&[9,10]), iter0.next());
assert_eq!(Some(&[11,12]), iter0.next());
assert_eq!(None, iter0.next());

pub fn iter_mut<'a>(
    &'a mut self
) -> <S::Type as IntoStaticChunkIterator<N>>::IterType where
    S: ViewMut<'a>,
    <S as ViewMut<'a>>::Type: IntoStaticChunkIterator<N>, 
[src]

Produce an iterator over mutably borrowed grouped elements of UniChunked.

Examples

The following example shows a simple modification of a uniformly organized Vec.

use flatk::*;
let mut s = UniChunked::<_, U2>::from_flat(vec![0,1,2,3]);
for i in s.iter_mut() {
    i[0] += 1;
    i[1] += 1;
}
let mut iter = s.iter();
assert_eq!(Some(&[1,2]), iter.next());
assert_eq!(Some(&[3,4]), iter.next());
assert_eq!(None, iter.next());

Nested UniChunkeds can also be modified as follows:

use flatk::*;
let mut s0 = UniChunked::<_, U2>::from_flat(vec![1,2, 3,4, 5,6, 7,8, 9,10, 11,12]);
let mut s1 = UniChunked::<_, U3>::from_flat(s0);
for mut i in s1.iter_mut() {
    for j in i.iter_mut() {
        j[0] += 1;
        j[1] += 2;
    }
}
let mut iter1 = s1.iter();
let s0 = iter1.next().unwrap();
let mut iter0 = s0.iter();
assert_eq!(Some(&[2,4]), iter0.next());
assert_eq!(Some(&[4,6]), iter0.next());
assert_eq!(Some(&[6,8]), iter0.next());
assert_eq!(None, iter0.next());
let s0 = iter1.next().unwrap();
let mut iter0 = s0.iter();
assert_eq!(Some(&[8,10]), iter0.next());
assert_eq!(Some(&[10,12]), iter0.next());
assert_eq!(Some(&[12,14]), iter0.next());
assert_eq!(None, iter0.next());

impl<S> UniChunked<S, usize>[src]

Important traits for Chunks<S>
pub fn iter<'a>(&'a self) -> Chunks<S::Type> where
    S: View<'a>, 
[src]

Important traits for Chunks<S>
pub fn iter_mut<'a>(&'a mut self) -> Chunks<S::Type> where
    S: ViewMut<'a>, 
[src]

Mutably iterate over Chunked data.

Example

use flatk::*;
let mut s = ChunkedN::from_flat_with_stride(vec![1,2,3,4,5,6], 3);
s.view_mut().isolate(1).copy_from_slice(&[0; 3]);
let mut iter = s.iter();
assert_eq!(Some(&[1,2,3][..]), iter.next());
assert_eq!(Some(&[0,0,0][..]), iter.next());
assert_eq!(None, iter.next());

Trait Implementations

impl<S: Set + ReinterpretAsGrouped<N>, N: Array<<S as Set>::Elem> + Unsigned> AsRef<[<N as Array<<S as Set>::Elem>>::Array]> for UniChunked<S, U<N>> where
    <S as ReinterpretAsGrouped<N>>::Output: AsRef<[N::Array]>,
    S: AsRef<[<S as Set>::Elem]>, 
[src]

impl<'a, S, N> AtomIterator<'a> for UniChunked<S, N> where
    S: AtomIterator<'a>, 
[src]

type Item = S::Item

type Iter = S::Iter

impl<'a, S, N> AtomMutIterator<'a> for UniChunked<S, N> where
    S: AtomMutIterator<'a>, 
[src]

type Item = S::Item

type Iter = S::Iter

impl<S, N: Dimension> ChunkSize for UniChunked<S, N>[src]

fn chunk_size(&self) -> usize[src]

Get the size of each chunk in this collection.

impl<S: Clear, N> Clear for UniChunked<S, N>[src]

impl<S: Clone, N: Clone> Clone for UniChunked<S, N>[src]

impl<T, S: CloneIntoOther<T>, N> CloneIntoOther<UniChunked<T, N>> for UniChunked<S, N>[src]

impl<T, S: CloneWithStorage<T>, N: Clone> CloneWithStorage<T> for UniChunked<S, N>[src]

type CloneType = UniChunked<S::CloneType, N>

impl<S: Copy, N: Copy> Copy for UniChunked<S, N>[src]

impl<S: Debug, N: Debug> Debug for UniChunked<S, N>[src]

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

impl<S: Dummy, N: Default> Dummy for UniChunked<S, N>[src]

impl<S, N> Extend<<UniChunked<S, U<N>> as Set>::Elem> for UniChunked<S, U<N>> where
    N: Unsigned,
    S: Set + UniChunkable<N> + PushChunk<N>, 
[src]

fn extend<T>(&mut self, iter: T) where
    T: IntoIterator<Item = Self::Elem>, 
[src]

Extend a UniChunked collection from an iterator over set elements.

Example

use flatk::*;

let v = vec![[1,2,3],[4,5,6]];
let mut s = Chunked3::from_array_vec(v);

let more = vec![[7,8,9],[10,11,12]];
s.extend(more.iter().cloned());
let mut iter = s.iter();
assert_eq!(Some(&[1,2,3]), iter.next());
assert_eq!(Some(&[4,5,6]), iter.next());
assert_eq!(Some(&[7,8,9]), iter.next());
assert_eq!(Some(&[10,11,12]), iter.next());
assert_eq!(None, iter.next());

impl<S, N> ExtendFromSlice for UniChunked<S, U<N>> where
    S: Set + ExtendFromSlice<Item = <S as Set>::Elem>,
    N: Unsigned + Array<<S as Set>::Elem>, 
[src]

type Item = N::Array

impl<S, N> FromIterator<<S as UniChunkable<N>>::Chunk> for UniChunked<S, U<N>> where
    N: Unsigned + Default,
    S: Set + UniChunkable<N> + PushChunk<N> + Default
[src]

fn from_iter<T>(iter: T) -> Self where
    T: IntoIterator<Item = S::Chunk>, 
[src]

Construct a UniChunked collection from an iterator that produces chunked elements.

Example

use flatk::*;
let v = vec![[1,2,3],[4,5,6]];
let s: Chunked3::<Vec<usize>> = v.into_iter().collect();
let mut iter = s.iter();
assert_eq!(Some(&[1,2,3]), iter.next());
assert_eq!(Some(&[4,5,6]), iter.next());
assert_eq!(None, iter.next());

impl<'a, S, N> GetIndex<'a, UniChunked<S, U<N>>> for usize where
    S: Set + UniChunkable<N> + Get<'a, StaticRange<N>>,
    N: Unsigned
[src]

type Output = S::Output

fn get(self, chunked: &UniChunked<S, U<N>>) -> Option<Self::Output>[src]

Get an element of the given UniChunked collection.

impl<'a, S, N> GetIndex<'a, UniChunked<S, U<N>>> for Range<usize> where
    S: Set + UniChunkable<N> + Get<'a, Range<usize>>,
    N: Unsigned + Default
[src]

type Output = UniChunked<S::Output, U<N>>

fn get(self, chunked: &UniChunked<S, U<N>>) -> Option<Self::Output>[src]

Get a [begin..end) subview of the given UniChunked collection.

impl<'a, S> GetIndex<'a, UniChunked<S, usize>> for usize where
    S: Set + Get<'a, Range<usize>>, 
[src]

type Output = S::Output

fn get(self, chunked: &ChunkedN<S>) -> Option<Self::Output>[src]

Get an element of the given ChunkedN collection.

impl<'a, S> GetIndex<'a, UniChunked<S, usize>> for Range<usize> where
    S: Set + Get<'a, Range<usize>>, 
[src]

type Output = ChunkedN<S::Output>

fn get(self, chunked: &ChunkedN<S>) -> Option<Self::Output>[src]

Get a [begin..end) subview of the given ChunkedN collection.

impl<T, N> Index<usize> for UniChunked<Vec<T>, U<N>> where
    N: Unsigned + Array<T>, 
[src]

type Output = N::Array

The returned type after indexing.

fn index(&self, idx: usize) -> &Self::Output[src]

Index the UniChunked Vec by usize. Note that this works for chunked collections that are themselves not chunked, since the item at the index of a doubly chunked collection is itself chunked, which cannot be represented by a single borrow. For more complex indexing use the get method provided by the Get trait.

Example

use flatk::*;
let s = Chunked3::from_flat(vec![1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]);
assert_eq!([7,8,9], s[2]);

impl<'_, T, N> Index<usize> for UniChunked<&'_ [T], U<N>> where
    N: Unsigned + Array<T>, 
[src]

type Output = N::Array

The returned type after indexing.

fn index(&self, idx: usize) -> &Self::Output[src]

Immutably index the UniChunked borrowed slice by usize. Note that this works for chunked collections that are themselves not chunked, since the item at the index of a doubly chunked collection is itself chunked, which cannot be represented by a single borrow. For more complex indexing use the get method provided by the Get trait.

Example

use flatk::*;
let s = Chunked3::from_flat(vec![1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]);
assert_eq!([7,8,9], s.view()[2]);

impl<'_, T, N> Index<usize> for UniChunked<&'_ mut [T], U<N>> where
    N: Unsigned + Array<T>, 
[src]

type Output = N::Array

The returned type after indexing.

fn index(&self, idx: usize) -> &Self::Output[src]

Immutably index the UniChunked mutably borrowed slice by usize. Note that this works for chunked collections that are themselves not chunked, since the item at the index of a doubly chunked collection is itself chunked, which cannot be represented by a single borrow. For more complex indexing use the get method provided by the Get trait.

Example

use flatk::*;
let mut s = Chunked3::from_flat(vec![1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]);
assert_eq!([7,8,9], s.view_mut()[2]);

impl<T, N> IndexMut<usize> for UniChunked<Vec<T>, U<N>> where
    N: Unsigned + Array<T>, 
[src]

fn index_mut(&mut self, idx: usize) -> &mut Self::Output[src]

Mutably index the UniChunked Vec by usize. Note that this works for chunked collections that are themselves not chunked, since the item at the index of a doubly chunked collection is itself chunked, which cannot be represented by a single borrow. For more complex indexing use the get method provided by the Get trait.

Example

use flatk::*;
let mut v = vec![1,2,3,4,5,6,0,0,0,10,11,12];
let mut s = Chunked3::from_flat(v);
s[2] = [7,8,9];
assert_eq!(vec![1,2,3,4,5,6,7,8,9,10,11,12], s.into_flat().to_vec());

impl<'_, T, N> IndexMut<usize> for UniChunked<&'_ mut [T], U<N>> where
    N: Unsigned + Array<T>, 
[src]

fn index_mut(&mut self, idx: usize) -> &mut Self::Output[src]

Mutably index the UniChunked mutably borrowed slice by usize. Note that this works for chunked collections that are themselves not chunked, since the item at the index of a doubly chunked collection is itself chunked, which cannot be represented by a single borrow. For more complex indexing use the get method provided by the Get trait.

Example

use flatk::*;
let mut v = vec![1,2,3,4,5,6,0,0,0,10,11,12];
let mut s = Chunked3::from_flat(v.as_mut_slice());
s[2] = [7,8,9];
assert_eq!(vec![1,2,3,4,5,6,7,8,9,10,11,12], v);

impl<'a, T: Clone, N: Array<T> + Unsigned> Into<&'a [<N as Array<T>>::Array]> for UniChunked<&'a [T], U<N>>[src]

impl<'a, T: Clone, N: Array<T> + Unsigned> Into<&'a mut [<N as Array<T>>::Array]> for UniChunked<&'a mut [T], U<N>>[src]

impl<T: Clone, N: Array<T> + Unsigned> Into<Vec<<N as Array<T>>::Array>> for UniChunked<Vec<T>, U<N>>[src]

impl<S: IntoFlat, N> IntoFlat for UniChunked<S, N>[src]

type FlatType = <S as IntoFlat>::FlatType

fn into_flat(self) -> Self::FlatType[src]

Strip away the uniform organization of the underlying data, and return the underlying data.

impl<S, N> IntoIterator for UniChunked<S, U<N>> where
    S: Set + IntoStaticChunkIterator<N>,
    N: Unsigned
[src]

type Item = <S as IntoStaticChunkIterator<N>>::Item

The type of the elements being iterated over.

type IntoIter = <S as IntoStaticChunkIterator<N>>::IterType

Which kind of iterator are we turning this into?

fn into_iter(self) -> Self::IntoIter[src]

Convert a UniChunked collection into an iterator over grouped elements.

Example

use flatk::*;
let mut s = UniChunked::<_, U3>::from_flat(vec![1,2,3,4,5,6]);
let mut iter = s.into_iter();
assert_eq!(Some([1,2,3]), iter.next());
assert_eq!(Some([4,5,6]), iter.next());
assert_eq!(None, iter.next());

impl<S, N> IntoOwned for UniChunked<S, N> where
    S: IntoOwned,
    N: Copy
[src]

type Owned = UniChunked<<S as IntoOwned>::Owned, N>

fn into_owned(self) -> Self::Owned[src]

Convert this UniChunked collection to an owned one.

Example

use flatk::*;
let v = vec![1,2,3,4,5,6];
let s_view = UniChunked::<_, U3>::from_flat(v.as_slice());
let s_owned = UniChunked::<_, U3>::from_flat(v.clone());
assert_eq!(s_view.into_owned(), s_owned);

impl<S, N> IntoOwnedData for UniChunked<S, N> where
    S: IntoOwnedData,
    N: Copy
[src]

type OwnedData = UniChunked<S::OwnedData, N>

impl<S, N, M> IntoStaticChunkIterator<N> for UniChunked<S, M> where
    Self: Set + SplitPrefix<N> + Dummy,
    N: Unsigned
[src]

type Item = Self::Prefix

type IterType = UniChunkedIter<Self, N>

impl<S, N, M> IsolateIndex<UniChunked<S, U<M>>> for StaticRange<N> where
    S: Set,
    M: Unsigned,
    N: Unsigned + Mul<M>,
    StaticRange<<N as Mul<M>>::Output>: IsolateIndex<S>, 
[src]

type Output = UniChunked<<StaticRange<N::Output> as IsolateIndex<S>>::Output, U<M>>

impl<S, N> IsolateIndex<UniChunked<S, U<N>>> for usize where
    S: Set + UniChunkable<N> + Isolate<StaticRange<N>>,
    N: Unsigned
[src]

type Output = S::Output

fn try_isolate(self, chunked: UniChunked<S, U<N>>) -> Option<Self::Output>[src]

Isolate a chunk of the given UniChunked collection.

impl<S, N> IsolateIndex<UniChunked<S, U<N>>> for Range<usize> where
    S: Set + UniChunkable<N> + Isolate<Range<usize>>,
    N: Unsigned + Default
[src]

type Output = UniChunked<S::Output, U<N>>

fn try_isolate(self, chunked: UniChunked<S, U<N>>) -> Option<Self::Output>[src]

Isolate a [begin..end) range of the given UniChunked collection.

impl<S> IsolateIndex<UniChunked<S, usize>> for usize where
    S: Set + Isolate<Range<usize>>, 
[src]

type Output = S::Output

fn try_isolate(self, chunked: ChunkedN<S>) -> Option<Self::Output>[src]

Isolate a chunk of the given ChunkedN collection.

impl<S> IsolateIndex<UniChunked<S, usize>> for Range<usize> where
    S: Set + Isolate<Range<usize>>, 
[src]

type Output = ChunkedN<S::Output>

fn try_isolate(self, chunked: ChunkedN<S>) -> Option<Self::Output>[src]

Isolate a [begin..end) range of the given ChunkedN collection.

impl<S, N: Unsigned> IsolateIndex<UniChunked<S, usize>> for StaticRange<N> where
    Range<usize>: IsolateIndex<ChunkedN<S>>, 
[src]

type Output = <Range<usize> as IsolateIndex<ChunkedN<S>>>::Output

impl<S: PartialEq, N: PartialEq> PartialEq<UniChunked<S, N>> for UniChunked<S, N>[src]

impl<S: Dummy, N: Unsigned + Default> PermuteInPlace for UniChunked<S, U<N>> where
    ChunkedN<S>: PermuteInPlace
[src]

fn permute_in_place(&mut self, permutation: &[usize], seen: &mut [bool])[src]

Permute this collection according to the given permutation. The given permutation must have length equal to this collection. The slice seen is provided to keep track of which elements have already been seen. seen is assumed to be initialized to false and have length equal or larger than this collection.

impl<'a, S, N> Push<<S as UniChunkable<N>>::Chunk> for UniChunked<S, U<N>> where
    N: Unsigned,
    S: Set + UniChunkable<N> + PushChunk<N>, 
[src]

fn push(&mut self, element: S::Chunk)[src]

Push a grouped element onto the UniChunked type. The pushed element must have exactly N sub-elements.

Example

use flatk::*;
let mut s = UniChunked::<_, U3>::from_flat(vec![1,2,3]);
s.push([4,5,6]);
let mut iter = s.iter();
assert_eq!(Some(&[1,2,3]), iter.next());
assert_eq!(Some(&[4,5,6]), iter.next());
assert_eq!(None, iter.next());

impl<S, M, N> PushChunk<M> for UniChunked<S, U<N>> where
    S: Set + PushChunk<<N as Mul<M>>::Output> + UniChunkable<<N as Mul<M>>::Output>,
    N: Mul<M>, 
[src]

impl<'a, S, N, M> ReinterpretAsGrouped<N> for UniChunked<S, U<M>> where
    S: ReinterpretAsGrouped<M>,
    <S as ReinterpretAsGrouped<M>>::Output: ReinterpretAsGrouped<N>, 
[src]

impl<S: RemovePrefix, N: Unsigned> RemovePrefix for UniChunked<S, U<N>>[src]

Required for building Subsets of UniChunked types.

impl<S: Reserve, N: Dimension> Reserve for UniChunked<S, N>[src]

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

An implementation of Set for a UniChunked collection of any type that can be grouped as N sub-elements.

type Elem = S::Chunk

Owned element of the set.

type Atom = S::Atom

The most basic element contained by this collection. If this collection contains other collections, this type should be different than Elem. Read more

fn len(&self) -> usize[src]

Compute the length of this UniChunked collection as the number of grouped elements in the set.

Example

use flatk::*;
let s = UniChunked::<_, U2>::from_flat(vec![0,1,2,3,4,5]);
assert_eq!(s.len(), 3);
let s = UniChunked::<_, U3>::from_flat(vec![0,1,2,3,4,5]);
assert_eq!(s.len(), 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<S: SplitPrefix<N> + Set, N: Copy> SplitFirst for UniChunked<S, U<N>>[src]

type First = S::Prefix

impl<S, N, M> SplitPrefix<M> for UniChunked<S, U<N>> where
    S: SplitPrefix<<N as Mul<M>>::Output> + Set,
    N: Unsigned + Mul<M> + Copy,
    M: Unsigned
[src]

type Prefix = UniChunked<S::Prefix, U<N>>

impl<S: Storage, N> Storage for UniChunked<S, N>[src]

type Storage = S::Storage

fn storage(&self) -> &Self::Storage[src]

Return an immutable reference to the underlying storage type.

Example

use flatk::*;
let v = vec![1,2,3,4,5,6,7,8,9,10,11,12];
let s0 = Chunked2::from_flat(v.clone());
let s1 = ChunkedN::from_flat_with_stride(s0.clone(), 3);
assert_eq!(s1.storage(), &v);
assert_eq!(s0.storage(), &v);

impl<S: StorageInto<T>, N, T> StorageInto<T> for UniChunked<S, N>[src]

Pass through the conversion for structure type UniChunked.

type Output = UniChunked<S::Output, N>

impl<S: StorageMut, N> StorageMut for UniChunked<S, N>[src]

fn storage_mut(&mut self) -> &mut Self::Storage[src]

Return a mutable reference to the underlying storage type.

Example

use flatk::*;
let mut v = vec![1,2,3,4,5,6,7,8,9,10,11,12];
let mut s0 = Chunked2::from_flat(v.clone());
let mut s1 = ChunkedN::from_flat_with_stride(s0.clone(), 3);
assert_eq!(s1.storage_mut(), &mut v);
assert_eq!(s0.storage_mut(), &mut v);

impl<'a, S: StorageView<'a>, N> StorageView<'a> for UniChunked<S, N>[src]

type StorageView = S::StorageView

fn storage_view(&'a self) -> Self::StorageView[src]

Return a view to the underlying storage type.

Example

use flatk::*;
let v = vec![1,2,3,4,5,6,7,8,9,10,11,12];
let s0 = Chunked2::from_flat(v.clone());
let s1 = ChunkedN::from_flat_with_stride(s0.clone(), 3);
assert_eq!(s1.storage_view(), v.as_slice());
assert_eq!(s0.storage_view(), v.as_slice());

impl<S, N> StructuralPartialEq for UniChunked<S, N>[src]

impl<S: SwapChunks, N: Unsigned> SwapChunks for UniChunked<S, U<N>>[src]

impl<S: Truncate, N: Unsigned> Truncate for UniChunked<S, U<N>>[src]

impl<S, N, M> UniChunkable<M> for UniChunked<S, U<N>> where
    S: UniChunkable<<N as Mul<M>>::Output>,
    N: Mul<M>, 
[src]

type Chunk = UniChunked<S::Chunk, U<N>>

impl<S, N> ValueType for UniChunked<S, N>[src]

impl<'a, S, N> View<'a> for UniChunked<S, N> where
    S: View<'a>,
    N: Copy
[src]

type Type = UniChunked<<S as View<'a>>::Type, N>

fn view(&'a self) -> Self::Type[src]

Create a UniChunked contiguous immutable (shareable) view into the underlying collection.

Example

use flatk::*;
let s = UniChunked::<_, U2>::from_flat(vec![0,1,2,3]);
let v1 = s.view(); // s is now inaccessible.
let v2 = v1.clone();
let mut view1_iter = v1.iter();
assert_eq!(Some(&[0,1]), view1_iter.next());
assert_eq!(Some(&[2,3]), view1_iter.next());
assert_eq!(None, view1_iter.next());
for ((a, b), c) in v1.iter().zip(v2.iter()).zip(s.iter()) {
    assert_eq!(a,b);
    assert_eq!(b,c);
}

impl<'a, S, N> ViewIterator<'a> for UniChunked<S, U<N>> where
    S: View<'a>,
    <S as View<'a>>::Type: IntoStaticChunkIterator<N>,
    N: Unsigned
[src]

type Item = <S::Type as IntoStaticChunkIterator<N>>::Item

type Iter = <S::Type as IntoStaticChunkIterator<N>>::IterType

impl<'a, S, N> ViewMut<'a> for UniChunked<S, N> where
    S: ViewMut<'a>,
    N: Copy
[src]

type Type = UniChunked<<S as ViewMut<'a>>::Type, N>

fn view_mut(&'a mut self) -> Self::Type[src]

Create a UniChunked contiguous mutable (unique) view into the underlying collection.

Example

use flatk::*;
let mut s = Chunked2::from_flat(vec![0,1,2,3]);
let mut v = s.view_mut();
{
   v.iter_mut().next().unwrap()[0] = 100;
}
let mut view_iter = v.iter();
assert_eq!(Some(&[100,1]), view_iter.next());
assert_eq!(Some(&[2,3]), view_iter.next());
assert_eq!(None, view_iter.next());

impl<'a, S, N> ViewMutIterator<'a> for UniChunked<S, U<N>> where
    S: ViewMut<'a>,
    <S as ViewMut<'a>>::Type: IntoStaticChunkIterator<N>,
    N: Unsigned
[src]

type Item = <S::Type as IntoStaticChunkIterator<N>>::Item

type Iter = <S::Type as IntoStaticChunkIterator<N>>::IterType

impl<S: Viewed, N> Viewed for UniChunked<S, N>[src]

Auto Trait Implementations

impl<S, N> RefUnwindSafe for UniChunked<S, N> where
    N: RefUnwindSafe,
    S: RefUnwindSafe

impl<S, N> Send for UniChunked<S, N> where
    N: Send,
    S: Send

impl<S, N> Sync for UniChunked<S, N> where
    N: Sync,
    S: Sync

impl<S, N> Unpin for UniChunked<S, N> where
    N: Unpin,
    S: Unpin

impl<S, N> UnwindSafe for UniChunked<S, N> where
    N: UnwindSafe,
    S: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> AsSlice<T> for T[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<'a, S, I> Get<'a, I> for S where
    I: GetIndex<'a, S>, 
[src]

type Output = <I as GetIndex<'a, S>>::Output

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<S> IntoChunkIterator for S where
    S: Set + SplitAt + Dummy
[src]

type Item = S

type IterType = ChunkedNIter<S>

impl<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

impl<T> IntoParallelIterator for T where
    T: ParallelIterator
[src]

type Iter = T

The parallel iterator type that will be created.

type Item = <T as ParallelIterator>::Item

The type of item that the parallel iterator will produce.

impl<S, I> Isolate<I> for S where
    I: IsolateIndex<S>, 
[src]

type Output = <I as IsolateIndex<S>>::Output

impl<T> Same<T> for T[src]

type Output = T

Should always be Self

impl<T> StaticallySplittable for T where
    T: IntoStaticChunkIterator<UInt<UInt<UTerm, B1>, B0>> + IntoStaticChunkIterator<UInt<UInt<UTerm, B1>, B1>> + IntoStaticChunkIterator<UInt<UInt<UInt<UTerm, B1>, B0>, B0>> + IntoStaticChunkIterator<UInt<UInt<UInt<UTerm, B1>, B0>, B1>> + IntoStaticChunkIterator<UInt<UInt<UInt<UTerm, B1>, B1>, B0>> + IntoStaticChunkIterator<UInt<UInt<UInt<UTerm, B1>, B1>, B1>> + IntoStaticChunkIterator<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>> + IntoStaticChunkIterator<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B1>> + IntoStaticChunkIterator<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B1>, B0>> + IntoStaticChunkIterator<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B1>, B1>> + IntoStaticChunkIterator<UInt<UInt<UInt<UInt<UTerm, B1>, B1>, B0>, B0>> + IntoStaticChunkIterator<UInt<UInt<UInt<UInt<UTerm, B1>, B1>, B0>, B1>> + IntoStaticChunkIterator<UInt<UInt<UInt<UInt<UTerm, B1>, B1>, B1>, B0>> + IntoStaticChunkIterator<UInt<UInt<UInt<UInt<UTerm, B1>, B1>, B1>, B1>> + IntoStaticChunkIterator<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.