Trait flatk::GetIndex [−][src]
pub trait GetIndex<'a, S> where
S: ?Sized, {
type Output;
fn get(self, set: &S) -> Option<Self::Output>;
unsafe fn at_unchecked(self, set: &S) -> Self::Output
where
Self: Sized,
{ ... }
}
Expand description
A helper trait analogous to SliceIndex
from the standard library.
Associated Types
Required methods
Provided methods
Implementations on Foreign Types
impl<'a, S, N> GetIndex<'a, UniChunked<S, U<N>>> for usize where
S: Set + UniChunkable<N> + Get<'a, StaticRange<N>>,
N: Unsigned,
impl<'a, S, N> GetIndex<'a, UniChunked<S, U<N>>> for usize where
S: Set + UniChunkable<N> + Get<'a, StaticRange<N>>,
N: Unsigned,
impl<'a, S, N> GetIndex<'a, UniChunked<S, U<N>>> for &usize where
S: Set + UniChunkable<N> + Get<'a, StaticRange<N>>,
N: Unsigned,
impl<'a, S, N> GetIndex<'a, UniChunked<S, U<N>>> for &usize where
S: Set + UniChunkable<N> + Get<'a, StaticRange<N>>,
N: Unsigned,
Get a [begin..end)
subview of the given UniChunked
collection.
type Output = UniChunked<S::Output, U<N>>
Get an element of the given Chunked
collection.
Example
use flatk::*;
let v = vec![0, 1, 4, 6];
let data = (1..=6).collect::<Vec<_>>();
let s = Chunked::from_offsets(v.as_slice(), data.view());
assert_eq!(Some(&[1][..]), s.get(0));
assert_eq!(Some(&[2,3,4][..]), s.get(1));
assert_eq!(Some(&[5,6][..]), s.get(2));
Get an element of the given Chunked
collection.
Example
use flatk::*;
let v = vec![0, 1, 4, 6];
let data = (1..=6).collect::<Vec<_>>();
let s = Chunked::from_offsets(v.as_slice(), data.view());
assert_eq!(Some(&[1][..]), s.get(&0));
assert_eq!(Some(&[2,3,4][..]), s.get(&1));
assert_eq!(Some(&[5,6][..]), s.get(&2));
Get a [begin..end)
subview of the given Chunked
collection.
Example
use flatk::*;
let data = (1..=6).collect::<Vec<_>>();
let offsets = vec![1, 2, 5, 7]; // Offsets don't have to start at 0
let s = Chunked::from_offsets(offsets.as_slice(), data.view());
let v = s.get(1..3).unwrap();
assert_eq!(Some(&[2,3,4][..]), v.get(0));
assert_eq!(Some(&[5,6][..]), v.get(1));