UniChunked

Struct UniChunked 

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

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: S§chunk_size: N

Implementations§

Source§

impl<T: Pod, N: Default + Array<T>> UniChunked<Vec<T>, U<N>>

Source

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

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]);
Source§

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

Source

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

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]);
Source§

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

Source

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

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]);
Source§

impl<S, N: Copy> UniChunked<S, N>

Source

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

Source§

impl<S, N> UniChunked<S, U<N>>
where S: Set, N: Array<<S as Set>::Elem>, <S as Set>::Elem: Pod,

Source

pub fn into_arrays(self) -> S::Output

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);
Source

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

Source

pub fn as_arrays<'a>(&'a self) -> <&'a S as ReinterpretAsGrouped<N>>::Output

Source§

impl<S: ChunkSize, N: Dimension> UniChunked<S, N>

Source

pub fn inner_chunk_size(&self) -> usize

Source§

impl<S, N> UniChunked<S, N>

Source

pub fn data(&self) -> &S

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());
Source

pub fn data_mut(&mut self) -> &mut S

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());
Source§

impl<S: Default, N: Default> UniChunked<S, U<N>>

Source

pub fn new() -> Self

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());
Source§

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

Source

pub fn from_flat(data: S) -> Self

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());
Source§

impl<S, N> UniChunked<S, N>

Source

pub fn into_inner(self) -> S

Convert this UniChunked collection into its inner representation.

Source§

impl<S: Default> UniChunked<S, usize>

Source

pub fn with_stride(n: usize) -> Self

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());
Source§

impl<S: Set> UniChunked<S, usize>

Source

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

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(3, 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());
Source§

impl<S, N> UniChunked<S, N>

Source

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

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

Source

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

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

Source§

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

Source

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

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

Source

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

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

Source§

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

Source

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

Source§

impl<T> UniChunked<Vec<T>, usize>

Source

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

Source§

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

Source

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

Source§

impl<T> UniChunked<Vec<T>, usize>

Source

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

Source§

impl<T, N> UniChunked<Vec<T>, U<N>>
where N: Array<T>, T: Clone + Pod,

Source

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

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]);
Source§

impl<S, N> UniChunked<S, U<N>>
where N: Unsigned,

Source

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

Produces an iterator over borrowed grouped elements of 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());
Source

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>,

Produces 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());
Source§

impl<S> UniChunked<S, usize>

Source

pub fn iter<'a>(&'a self) -> Chunks<S::Type>
where S: View<'a>,

Source

pub fn iter_mut<'a>(&'a mut self) -> Chunks<S::Type>
where S: ViewMut<'a>,

Mutably iterate over Chunked data.

§Example
use flatk::*;
let mut s = ChunkedN::from_flat_with_stride(3, vec![1,2,3,4,5,6]);
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§

Source§

impl<S, 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]> + Set + ReinterpretAsGrouped<N>, <S as Set>::Elem: Pod,

Source§

fn as_ref(&self) -> &[N::Array]

Converts this type into a shared reference of the (usually inferred) input type.
Source§

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

Source§

type Item = <S as AtomIterator<'a>>::Item

Source§

type Iter = <S as AtomIterator<'a>>::Iter

Source§

fn atom_iter(&'a self) -> Self::Iter

Source§

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

Source§

type Item = <S as AtomMutIterator<'a>>::Item

Source§

type Iter = <S as AtomMutIterator<'a>>::Iter

Source§

fn atom_mut_iter(&'a mut self) -> Self::Iter

Source§

impl<S, N: Dimension> ChunkSize for UniChunked<S, N>

Source§

fn chunk_size(&self) -> usize

Get the size of each chunk in this collection.

Source§

impl<S: Clear, N> Clear for UniChunked<S, N>

Source§

fn clear(&mut self)

Remove all elements from the current set without necessarily deallocating the space previously used.
Source§

impl<S: Clone, N: Clone> Clone for UniChunked<S, N>

Source§

fn clone(&self) -> UniChunked<S, N>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T, S: CloneIntoOther<T>, N> CloneIntoOther<UniChunked<T, N>> for UniChunked<S, N>

Source§

fn clone_into_other(&self, other: &mut UniChunked<T, N>)

Source§

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

Source§

impl<S: Debug, N: Debug> Debug for UniChunked<S, N>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

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

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<S: Dummy, N: Default> Dummy for UniChunked<S, N>

Source§

unsafe fn dummy() -> Self

Constructs a potentially invalid instance of a type. Read more
Source§

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>,

Source§

fn extend<T>(&mut self, iter: T)
where T: IntoIterator<Item = <Self as Set>::Elem>,

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());

We can do this with nested chunked types, although the we would need to first convert the incoming iterator into an appropriate chunked type, in this case it is Chunked2<[i32; 4]>.

use flatk::*;

let v = vec![[1i32,2],[3,4],[5,6],[7,8]];
let mut s = Chunked2::from_flat(Chunked2::from_array_vec(v));

let more = Chunked2::from_flat(Chunked2::from_array_vec(vec![[9, 10], [11, 12]]));
s.extend(more.into_iter());
let mut iter = s.iter().map(|i| i.into_arrays());
assert_eq!(Some(&[[1,2], [3,4]]), iter.next());
assert_eq!(Some(&[[5,6], [7,8]]), iter.next());
assert_eq!(Some(&[[9,10], [11,12]]), iter.next());
assert_eq!(None, iter.next());

In the wake of const-generics, this will become a whole lot more ergonomic.

Source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Source§

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>, <S as Set>::Elem: Pod,

Source§

type Item = <N as Array<<S as Set>::Elem>>::Array

Source§

fn extend_from_slice(&mut self, other: &[Self::Item])

Source§

impl<'a, T: Clone + Pod, N: Array<T> + Unsigned> From<UniChunked<&'a [T], U<N>>> for &'a [N::Array]

Source§

fn from(val: UniChunked<&'a [T], U<N>>) -> Self

Converts to this type from the input type.
Source§

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

Source§

fn from(val: UniChunked<&'a mut [T], U<N>>) -> Self

Converts to this type from the input type.
Source§

impl<T: Clone + Pod, N: Array<T> + Unsigned> From<UniChunked<Vec<T>, U<N>>> for Vec<N::Array>

Source§

fn from(val: UniChunked<Vec<T>, U<N>>) -> Self

Converts to this type from the input type.
Source§

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,

Source§

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

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());
Source§

impl<'a, S, N, M> GetIndex<'a, UniChunked<S, U<M>>> for StaticRange<N>
where S: Set, M: Unsigned, N: Unsigned + Mul<M>, StaticRange<<N as Mul<M>>::Output>: GetIndex<'a, S>,

Source§

fn get(self, chunked: &UniChunked<S, U<M>>) -> Option<Self::Output>

Get a statically sized subview of the given UniChunked collection.

Source§

type Output = UniChunked<<StaticRange<<N as Mul<M>>::Output> as GetIndex<'a, S>>::Output, U<M>>

Source§

unsafe fn at_unchecked(self, set: &S) -> Self::Output
where Self: Sized,

Gets the value in the set at this index. Read more
Source§

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

Source§

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

Get an element of the given UniChunked collection.

Source§

type Output = <S as Get<'a, StaticRange<N>>>::Output

Source§

unsafe fn at_unchecked(self, set: &S) -> Self::Output
where Self: Sized,

Gets the value in the set at this index. Read more
Source§

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,

Source§

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

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

Source§

type Output = UniChunked<<S as Get<'a, Range<usize>>>::Output, U<N>>

Source§

unsafe fn at_unchecked(self, set: &S) -> Self::Output
where Self: Sized,

Gets the value in the set at this index. Read more
Source§

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

Source§

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

Get an element of the given UniChunked collection.

Source§

type Output = <S as Get<'a, StaticRange<N>>>::Output

Source§

unsafe fn at_unchecked(self, set: &S) -> Self::Output
where Self: Sized,

Gets the value in the set at this index. Read more
Source§

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

Source§

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

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

Source§

type Output = UniChunked<<S as Get<'a, Range<usize>>>::Output, usize>

Source§

unsafe fn at_unchecked(self, set: &S) -> Self::Output
where Self: Sized,

Gets the value in the set at this index. Read more
Source§

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

Source§

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

Get an element of the given ChunkedN collection.

Source§

type Output = <S as Get<'a, Range<usize>>>::Output

Source§

unsafe fn at_unchecked(self, set: &S) -> Self::Output
where Self: Sized,

Gets the value in the set at this index. Read more
Source§

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

Source§

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

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]);
Source§

type Output = <N as Array<T>>::Array

The returned type after indexing.
Source§

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

Source§

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

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]);
Source§

type Output = <N as Array<T>>::Array

The returned type after indexing.
Source§

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

Source§

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

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]);
Source§

type Output = <N as Array<T>>::Array

The returned type after indexing.
Source§

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

Source§

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

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);
Source§

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

Source§

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

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 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_storage().to_vec());
Source§

impl<S, N> IntoIterator for UniChunked<S, U<N>>

Source§

fn into_iter(self) -> Self::IntoIter

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());
Source§

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

The type of the elements being iterated over.
Source§

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

Which kind of iterator are we turning this into?
Source§

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

Source§

fn into_owned(self) -> Self::Owned

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);
Source§

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

Source§

fn clone_into(self, target: &mut Self::Owned)

Source§

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

Source§

impl<S: IntoParChunkIterator, N: Dimension> IntoParallelIterator for UniChunked<S, N>

Source§

fn into_par_iter(self) -> Self::Iter

Convert a UniChunked collection into a parallel iterator over grouped elements.

Source§

type Item = <S as IntoParChunkIterator>::Item

The type of item that the parallel iterator will produce.
Source§

type Iter = <S as IntoParChunkIterator>::IterType

The parallel iterator type that will be created.
Source§

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

Source§

type Item = <UniChunked<S, M> as SplitPrefix<N>>::Prefix

Source§

type IterType = UniChunkedIter<UniChunked<S, M>, N>

Source§

fn into_static_chunk_iter(self) -> Self::IterType

This function should panic if this collection length is not a multiple of N.
Source§

fn into_generic_static_chunk_iter(self) -> UniChunkedIter<Self, N>

Simply call this method for all types that implement SplitPrefix<N>.
Source§

impl<S: IntoStorage, N> IntoStorage for UniChunked<S, N>

Source§

fn into_storage(self) -> Self::StorageType

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

Source§

type StorageType = <S as IntoStorage>::StorageType

Source§

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>,

Source§

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

Source§

unsafe fn isolate_unchecked(self, set: UniChunked<S, U<M>>) -> Self::Output

Attempts to isolate a value in the given set at this index. Read more
Source§

fn try_isolate(self, set: UniChunked<S, U<M>>) -> Option<Self::Output>

Attempts to isolate a value in the given set at this index. Read more
Source§

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

Source§

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

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

Source§

type Output = UniChunked<<S as Isolate<Range<usize>>>::Output, U<N>>

Source§

unsafe fn isolate_unchecked(self, chunked: UniChunked<S, U<N>>) -> Self::Output

Attempts to isolate a value in the given set at this index. Read more
Source§

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

Source§

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

Isolate a chunk of the given UniChunked collection.

Source§

type Output = <S as Isolate<StaticRange<N>>>::Output

Source§

unsafe fn isolate_unchecked(self, chunked: UniChunked<S, U<N>>) -> Self::Output

Attempts to isolate a value in the given set at this index. Read more
Source§

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

Source§

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

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

Source§

type Output = UniChunked<<S as Isolate<Range<usize>>>::Output, usize>

Source§

unsafe fn isolate_unchecked(self, chunked: ChunkedN<S>) -> Self::Output

Attempts to isolate a value in the given set at this index. Read more
Source§

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

Source§

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

Isolate a chunk of the given ChunkedN collection.

Source§

type Output = <S as Isolate<Range<usize>>>::Output

Source§

unsafe fn isolate_unchecked(self, chunked: ChunkedN<S>) -> Self::Output

Attempts to isolate a value in the given set at this index. Read more
Source§

impl<S: MapStorage<Out>, N, Out> MapStorage<Out> for UniChunked<S, N>

Map the underlying storage type.

Source§

type Input = <S as MapStorage<Out>>::Input

Source§

type Output = UniChunked<<S as MapStorage<Out>>::Output, N>

Source§

fn map_storage<F: FnOnce(Self::Input) -> Out>(self, f: F) -> Self::Output

Source§

impl<S: PartialEq, N: PartialEq> PartialEq for UniChunked<S, N>

Source§

fn eq(&self, other: &UniChunked<S, N>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<S: Dummy, N: Unsigned + Default> PermuteInPlace for UniChunked<S, U<N>>

Source§

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

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.

Source§

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

Source§

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

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());
Source§

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>,

Source§

fn push_chunk(&mut self, chunk: Self::Chunk)

Push a chunk with size N.
Source§

impl<'a, S, N, M> ReinterpretAsGrouped<N> for UniChunked<S, U<M>>

Source§

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

Required for building Subsets of UniChunked types.

Source§

fn remove_prefix(&mut self, n: usize)

Remove n elements from the beginning.
Source§

impl<S: Reserve, N: Dimension> Reserve for UniChunked<S, N>

Source§

fn reserve_with_storage(&mut self, n: usize, storage_n: usize)

Source§

fn reserve(&mut self, n: usize)

Source§

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

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

Source§

fn len(&self) -> usize

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);
Source§

type Elem = <S as UniChunkable<N>>::Chunk

Owned element of the set.
Source§

type Atom = <S as Set>::Atom

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

fn is_empty(&self) -> bool

Source§

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

Source§

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

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]));
Source§

impl<S: SplitPrefix<N> + Set, N: Copy> SplitFirst for UniChunked<S, U<N>>

Source§

type First = <S as SplitPrefix<N>>::Prefix

Source§

fn split_first(self) -> Option<(Self::First, Self)>

Source§

unsafe fn split_first_unchecked(self) -> (Self::First, Self)

Split off the first element without checking if one exists. Read more
Source§

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,

Source§

type Prefix = UniChunked<<S as SplitPrefix<<N as Mul<M>>::Output>>::Prefix, U<N>>

Source§

fn split_prefix(self) -> Option<(Self::Prefix, Self)>

Split N items from the beginning of the collection. Read more
Source§

impl<S: Storage, N> Storage for UniChunked<S, N>

Source§

fn storage(&self) -> &Self::Storage

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 mut s0 = Chunked2::from_flat(v.clone());
let s1 = ChunkedN::from_flat_with_stride(3, s0.clone());
assert_eq!(s1.storage(), &v);
assert_eq!(s0.storage(), &v);
assert_eq!(s0.view_mut().storage(), v.as_slice());
Source§

type Storage = <S as Storage>::Storage

Source§

impl<S: StorageInto<T>, N, T> StorageInto<T> for UniChunked<S, N>

Pass through the conversion for structure type UniChunked.

Source§

impl<S: StorageMut, N> StorageMut for UniChunked<S, N>

Source§

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

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(3, s0.clone());
assert_eq!(s1.storage_mut(), &mut v);
assert_eq!(s0.storage_mut(), &mut v);
Source§

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

Source§

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

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(3, s0.clone());
assert_eq!(s1.storage_view(), v.as_slice());
assert_eq!(s0.storage_view(), v.as_slice());
Source§

type StorageView = <S as StorageView<'a>>::StorageView

Source§

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

Source§

fn swap_chunks(&mut self, begin_a: usize, begin_b: usize, chunk_size: usize)

Swap equal sized contiguous chunks in this collection.
Source§

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

Source§

fn truncate(&mut self, new_len: usize)

Source§

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

Source§

type Chunk = UniChunked<<S as UniChunkable<<N as Mul<M>>::Output>>::Chunk, U<N>>

Source§

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

Source§

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

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);
}
Source§

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

Source§

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

Source§

type Item = <<S as View<'a>>::Type as IntoStaticChunkIterator<N>>::Item

Source§

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

Source§

fn view_iter(&'a self) -> Self::Iter

Source§

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

Source§

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

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());
Source§

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

Source§

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

Source§

type Item = <<S as ViewMut<'a>>::Type as IntoStaticChunkIterator<N>>::Item

Source§

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

Source§

fn view_mut_iter(&'a mut self) -> Self::Iter

Source§

impl<S: Copy, N: Copy> Copy for UniChunked<S, N>

Source§

impl<S, N> StructuralPartialEq for UniChunked<S, N>

Source§

impl<S, N> ValueType for UniChunked<S, N>

Source§

impl<S: Viewed, N> Viewed for UniChunked<S, N>

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

§

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

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

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

Source§

fn get(&self, idx: I) -> Option<<I as GetIndex<'a, S>>::Output>

Source§

fn at(&self, idx: I) -> Self::Output

Return a value at the given index. This is provided as the checked version of get that will panic if the equivalent get call is None, which typically means that the given index is out of bounds. Read more
Source§

unsafe fn at_unchecked(&self, idx: I) -> Self::Output

Return a value at the given index. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<S> IntoChunkIterator for S
where S: Set + SplitAt + Dummy,

Source§

type Item = S

Source§

type IterType = ChunkedNIter<S>

Source§

fn into_chunk_iter( self, chunk_size: usize, ) -> <S as IntoChunkIterator>::IterType

Produce a chunk iterator with the given stride chunk_size. One notable difference between this trait and chunks* methods on slices is that chunks_iter should panic when the underlying data cannot split into chunk_size sized chunks exactly.
Source§

impl<S, I> Isolate<I> for S
where I: IsolateIndex<S>,

Source§

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

Source§

unsafe fn isolate_unchecked(self, idx: I) -> <S as Isolate<I>>::Output

Unchecked version of isolate. Read more
Source§

fn try_isolate(self, idx: I) -> Option<<S as Isolate<I>>::Output>

Source§

fn isolate(self, idx: I) -> Self::Output
where Self: Sized,

Return a value at the given index. This is provided as the checked version of try_isolate that will panic if the equivalent try_isolate call is None, which typically means that the given index is out of bounds. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, N> PushArrayToVec<N> for T
where T: Clone, N: Array<T>,

Source§

fn push_to_vec(element: <N as Array<T>>::Array, set: &mut Vec<T>)

This method tells this type how it can be pushed to a Vec as an array.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> StaticallySplittable for T