Type Definition flatk::ChunkedN[][src]

pub type ChunkedN<S> = UniChunked<S, usize>;
Expand description

Define aliases for common uniform chunked types.

Implementations

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

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

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

Index the ChunkedN 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 = ChunkedN::from_flat_with_stride(3, vec![1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]);
assert_eq!([7,8,9], s[2]);

The returned type after indexing.

Immutably index the ChunkedN 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 = ChunkedN::from_flat_with_stride(3, vec![1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]);
assert_eq!([7,8,9], s.view()[2]);

The returned type after indexing.

Immutably index the ChunkedN 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 = ChunkedN::from_flat_with_stride(3, 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]);

The returned type after indexing.

Mutably index the ChunkedN 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 = ChunkedN::from_flat_with_stride(3, v);
s[2].copy_from_slice(&[7,8,9]);
assert_eq!(vec![1,2,3,4,5,6,7,8,9,10,11,12], s.into_storage().to_vec());

Mutably index the ChunkedN 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 = ChunkedN::from_flat_with_stride(3, v.as_mut_slice());
s[2].copy_from_slice(&[7,8,9]);
assert_eq!(vec![1,2,3,4,5,6,7,8,9,10,11,12], v);

Convert a ChunkedN collection into an iterator over grouped elements.

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

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

This is a more general implementation of permute in place that is also used for slices.

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.

Push a grouped element onto the ChunkedN type.

Example
use flatk::*;
let mut s = ChunkedN::from_flat_with_stride(3, 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());

Remove n elements from the beginning.

An implementation of Set for a UniChunked collection of any type that can be grouped into sub-elements whose size is determined at run-time.

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

Example
use flatk::*;
let s = ChunkedN::from_flat_with_stride(2, vec![0,1,2,3,4,5]);
assert_eq!(s.len(), 3);
let s = ChunkedN::from_flat_with_stride(3, vec![0,1,2,3,4,5]);
assert_eq!(s.len(), 2);

Owned element of the set.

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

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

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

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

Swap equal sized contiguous chunks in this collection.