[][src]Trait flatk::View

pub trait View<'a> {
    type Type: Viewed;
    fn view(&'a self) -> Self::Type;
}

A trait defining a collection that can be accessed via an immutable (shared) view. This type of view can be cloned and copied.

Associated Types

type Type: Viewed

Loading content...

Required methods

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

Loading content...

Implementations on Foreign Types

impl<'a, T: 'a> View<'a> for [T; 1][src]

type Type = &'a [T]

impl<'a, T: 'a> View<'a> for [T; 2][src]

type Type = &'a [T]

impl<'a, T: 'a> View<'a> for [T; 3][src]

type Type = &'a [T]

impl<'a, T: 'a> View<'a> for [T; 4][src]

type Type = &'a [T]

impl<'a, T: 'a> View<'a> for [T; 5][src]

type Type = &'a [T]

impl<'a, T: 'a> View<'a> for [T; 6][src]

type Type = &'a [T]

impl<'a, T: 'a> View<'a> for [T; 7][src]

type Type = &'a [T]

impl<'a, T: 'a> View<'a> for [T; 8][src]

type Type = &'a [T]

impl<'a, T: 'a> View<'a> for [T; 9][src]

type Type = &'a [T]

impl<'a, T: 'a> View<'a> for [T; 10][src]

type Type = &'a [T]

impl<'a, T: 'a> View<'a> for [T; 11][src]

type Type = &'a [T]

impl<'a, T: 'a> View<'a> for [T; 12][src]

type Type = &'a [T]

impl<'a, T: 'a> View<'a> for [T; 13][src]

type Type = &'a [T]

impl<'a, T: 'a> View<'a> for [T; 14][src]

type Type = &'a [T]

impl<'a, T: 'a> View<'a> for [T; 15][src]

type Type = &'a [T]

impl<'a, T: 'a> View<'a> for [T; 16][src]

type Type = &'a [T]

impl<'a, S: View<'a>> View<'a> for Box<S>[src]

type Type = <S as View<'a>>::Type

impl<'a, I: IntBound> View<'a> for Range<I>[src]

type Type = Self

impl<'a, I: IntBound> View<'a> for RangeInclusive<I>[src]

type Type = Self

impl<'a, I: IntBound> View<'a> for RangeTo<I>[src]

type Type = Self

impl<'a, I: IntBound> View<'a> for RangeToInclusive<I>[src]

type Type = Self

impl<'a, T: 'a> View<'a> for [T][src]

type Type = &'a [T]

impl<'a, S: View<'a>, T: View<'a>> View<'a> for (S, T)[src]

type Type = (S::Type, T::Type)

impl<'a, T: 'a> View<'a> for Vec<T>[src]

type Type = &'a [T]

impl<'a, '_, S: ?Sized + 'a + View<'a>> View<'a> for &'_ S[src]

Blanket implementation of View for all immutable borrows.

type Type = S::Type

impl<'a, '_, S: ?Sized + 'a + View<'a>> View<'a> for &'_ mut S[src]

Blanket implementation of View for all mutable borrows.

type Type = S::Type

Loading content...

Implementors

impl<'a, O: AsRef<[usize]>> View<'a> for Offsets<O>[src]

type Type = Offsets<&'a [usize]>

impl<'a, O: AsRef<[usize]>> View<'a> for SortedChunks<O>[src]

type Type = SortedChunks<&'a [usize]>

impl<'a, S, I> View<'a> for Select<S, I> where
    S: View<'a>,
    I: AsRef<[usize]>, 
[src]

type Type = Select<S::Type, &'a [usize]>

impl<'a, S, I> View<'a> for Subset<S, I> where
    S: View<'a>,
    I: AsRef<[usize]>, 
[src]

Required for Chunked and UniChunked subsets.

type Type = Subset<S::Type, &'a [usize]>

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, O> View<'a> for Chunked<S, O> where
    S: View<'a>,
    O: View<'a>, 
[src]

type Type = Chunked<S::Type, O::Type>

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

Create a contiguous immutable (shareable) view into this set.

Example

use flatk::*;
let s = Chunked::<Vec<usize>>::from_offsets(vec![0,1,4,6], vec![0,1,2,3,4,5]);
let v1 = s.view();
let v2 = v1.clone();
let mut view1_iter = v1.clone().into_iter();
assert_eq!(Some(&[0][..]), view1_iter.next());
assert_eq!(Some(&[1,2,3][..]), view1_iter.next());
assert_eq!(Some(&[4,5][..]), view1_iter.next());
assert_eq!(None, view1_iter.next());
for (a,b) in v1.into_iter().zip(v2.into_iter()) {
    assert_eq!(a,b);
}

impl<'a, S, T, I> View<'a> for Sparse<S, T, I> where
    S: View<'a>,
    T: View<'a>,
    I: AsRef<[usize]>, 
[src]

type Type = Sparse<S::Type, T::Type, &'a [usize]>

Loading content...