GetIndex

Trait GetIndex 

Source
pub trait GetIndex<'a, S>
where S: ?Sized,
{ type Output; // Required method fn get(self, set: &S) -> Option<Self::Output>; // Provided method unsafe fn at_unchecked(self, set: &S) -> Self::Output where Self: Sized { ... } }
Expand description

A helper trait analogous to SliceIndex from the standard library.

Required Associated Types§

Required Methods§

Source

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

Gets the value in the set at this index.

Provided Methods§

Source

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

Gets the value in the set at this index.

§Safety

The index must be within the bounds of the set to avoid undefined behavior (UB).

The default implementation panics if the index is out of bounds instead of causing UB.

Implementations on Foreign Types§

Source§

impl<'a, O> GetIndex<'a, ClumpedOffsets<O>> for &usize

Source§

type Output = usize

Source§

fn get(self, clumped_offsets: &ClumpedOffsets<O>) -> Option<Self::Output>

Source§

impl<'a, O> GetIndex<'a, ClumpedOffsets<O>> for usize

Source§

type Output = usize

Source§

fn get(self, clumped_offsets: &ClumpedOffsets<O>) -> Option<Self::Output>

Source§

impl<'a, O: Get<'a, usize>> GetIndex<'a, Offsets<O>> for &usize

Source§

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

Source§

fn get(self, offsets: &Offsets<O>) -> Option<Self::Output>

Source§

impl<'a, O: Get<'a, usize>> GetIndex<'a, Offsets<O>> for usize

Source§

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

Source§

fn get(self, offsets: &Offsets<O>) -> Option<Self::Output>

Source§

impl<'a, O: Get<'a, Range<usize>>> GetIndex<'a, Offsets<O>> for Range<usize>

Source§

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

Source§

fn get(self, offsets: &Offsets<O>) -> Option<Self::Output>

Source§

impl<'a, R> GetIndex<'a, R> for usize
where R: BoundedRange + Set,

Source§

type Output = <R as BoundedRange>::Index

Source§

fn get(self, rng: &R) -> Option<Self::Output>

Source§

impl<'a, R> GetIndex<'a, R> for Range<usize>
where R: BoundedRange + Set,

Source§

type Output = Range<<R as BoundedRange>::Index>

Source§

fn get(self, rng: &R) -> Option<Self::Output>

Source§

impl<'a, S> GetIndex<'a, Select<S, Range<usize>>> for &usize
where S: Get<'a, usize>,

Source§

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

Source§

fn get(self, selection: &Select<S, Range<usize>>) -> Option<Self::Output>

Source§

impl<'a, S> GetIndex<'a, Select<S, Range<usize>>> for usize
where S: Get<'a, usize>,

Source§

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

Source§

fn get(self, selection: &Select<S, Range<usize>>) -> Option<Self::Output>

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§

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§

impl<'a, S> GetIndex<'a, S> for RangeFrom<usize>
where S: Set + ValueType, Range<usize>: GetIndex<'a, S>,

Source§

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

Source§

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

Source§

impl<'a, S> GetIndex<'a, S> for RangeFull
where S: Set + ValueType, Range<usize>: GetIndex<'a, S>,

Source§

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

Source§

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

Source§

impl<'a, S, I> GetIndex<'a, Select<S, I>> for &usize
where I: AsIndexSlice, S: Get<'a, usize>,

Source§

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

Source§

fn get(self, selection: &Select<S, I>) -> Option<Self::Output>

Source§

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

Source§

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

Source§

fn get(self, selection: &Select<S, I>) -> Option<Self::Output>

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§

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§

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§

impl<'a, S, O> GetIndex<'a, Chunked<S, O>> for &usize
where S: Set + View<'a> + Get<'a, Range<usize>, Output = <S as View<'a>>::Type>, O: IndexRange,

Source§

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

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

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

Source§

impl<'a, S, O> GetIndex<'a, Chunked<S, O>> for usize
where S: Set + View<'a> + Get<'a, Range<usize>, Output = <S as View<'a>>::Type>, O: IndexRange,

Source§

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

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

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

Source§

impl<'a, S, O> GetIndex<'a, Chunked<S, O>> for Range<usize>
where S: Set + View<'a> + Get<'a, Range<usize>, Output = <S as View<'a>>::Type>, O: IndexRange + Get<'a, Range<usize>>,

Source§

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

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

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

Source§

impl<'a, S, O> GetIndex<'a, Subset<S, O>> for &usize
where O: AsRef<[usize]>, S: Get<'a, usize>,

Source§

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

Source§

fn get(self, subset: &Subset<S, O>) -> Option<Self::Output>

Source§

impl<'a, S, O> GetIndex<'a, Subset<S, O>> for usize
where O: AsRef<[usize]>, S: Get<'a, usize>,

Source§

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

Source§

fn get(self, subset: &Subset<S, O>) -> Option<Self::Output>

Source§

impl<'a, S, T> GetIndex<'a, (S, T)> for usize
where S: Get<'a, usize>, T: Get<'a, usize>,

Source§

type Output = (<S as Get<'a, usize>>::Output, <T as Get<'a, usize>>::Output)

Source§

fn get(self, (s, t): &(S, T)) -> Option<Self::Output>

Source§

impl<'a, S, T> GetIndex<'a, (S, T)> for Range<usize>
where S: Get<'a, Range<usize>>, T: Get<'a, Range<usize>>,

Source§

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

Source§

fn get(self, (s, t): &(S, T)) -> Option<Self::Output>

Source§

impl<'a, S, T, I> GetIndex<'a, Sparse<S, T, I>> for &usize
where I: AsIndexSlice, S: Get<'a, usize>,

Source§

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

Source§

fn get(self, sparse: &Sparse<S, T, I>) -> Option<Self::Output>

Source§

impl<'a, S, T, I> GetIndex<'a, Sparse<S, T, I>> for usize
where I: AsIndexSlice, S: Get<'a, usize>,

Source§

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

Source§

fn get(self, sparse: &Sparse<S, T, I>) -> Option<Self::Output>

Source§

impl<'a, S: ValueType> GetIndex<'a, S> for RangeInclusive<usize>
where Range<usize>: GetIndex<'a, S>,

Source§

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

Source§

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

Source§

impl<'a, S: ValueType> GetIndex<'a, S> for RangeTo<usize>
where Range<usize>: GetIndex<'a, S>,

Source§

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

Source§

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

Source§

impl<'a, S: ValueType> GetIndex<'a, S> for RangeToInclusive<usize>
where Range<usize>: GetIndex<'a, S>,

Source§

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

Source§

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

Implementors§

Source§

impl<'a, S, N> GetIndex<'a, S> for StaticRange<N>

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§

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

Source§

impl<'a, S, T, N> GetIndex<'a, (S, T)> for StaticRange<N>
where S: Get<'a, StaticRange<N>>, T: Get<'a, StaticRange<N>>, N: Unsigned + Copy,

Source§

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

Source§

impl<'a, T, I> GetIndex<'a, &'a [T]> for I
where I: SliceIndex<[T]>, <[T] as Index<I>>::Output: 'a,

Source§

type Output = &'a <[T] as Index<I>>::Output

Source§

impl<'a, T, N> GetIndex<'a, &'a [T; 1]> for StaticRange<N>
where N: Unsigned + Array<T>, <N as Array<T>>::Array: 'a,

Source§

type Output = &'a <N as Array<T>>::Array

Source§

impl<'a, T, N> GetIndex<'a, &'a [T; 2]> for StaticRange<N>
where N: Unsigned + Array<T>, <N as Array<T>>::Array: 'a,

Source§

type Output = &'a <N as Array<T>>::Array

Source§

impl<'a, T, N> GetIndex<'a, &'a [T; 3]> for StaticRange<N>
where N: Unsigned + Array<T>, <N as Array<T>>::Array: 'a,

Source§

type Output = &'a <N as Array<T>>::Array

Source§

impl<'a, T, N> GetIndex<'a, &'a [T; 4]> for StaticRange<N>
where N: Unsigned + Array<T>, <N as Array<T>>::Array: 'a,

Source§

type Output = &'a <N as Array<T>>::Array

Source§

impl<'a, T, N> GetIndex<'a, &'a [T; 5]> for StaticRange<N>
where N: Unsigned + Array<T>, <N as Array<T>>::Array: 'a,

Source§

type Output = &'a <N as Array<T>>::Array

Source§

impl<'a, T, N> GetIndex<'a, &'a [T; 6]> for StaticRange<N>
where N: Unsigned + Array<T>, <N as Array<T>>::Array: 'a,

Source§

type Output = &'a <N as Array<T>>::Array

Source§

impl<'a, T, N> GetIndex<'a, &'a [T; 7]> for StaticRange<N>
where N: Unsigned + Array<T>, <N as Array<T>>::Array: 'a,

Source§

type Output = &'a <N as Array<T>>::Array

Source§

impl<'a, T, N> GetIndex<'a, &'a [T; 8]> for StaticRange<N>
where N: Unsigned + Array<T>, <N as Array<T>>::Array: 'a,

Source§

type Output = &'a <N as Array<T>>::Array

Source§

impl<'a, T, N> GetIndex<'a, &'a [T; 9]> for StaticRange<N>
where N: Unsigned + Array<T>, <N as Array<T>>::Array: 'a,

Source§

type Output = &'a <N as Array<T>>::Array

Source§

impl<'a, T, N> GetIndex<'a, &'a [T; 10]> for StaticRange<N>
where N: Unsigned + Array<T>, <N as Array<T>>::Array: 'a,

Source§

type Output = &'a <N as Array<T>>::Array

Source§

impl<'a, T, N> GetIndex<'a, &'a [T; 11]> for StaticRange<N>
where N: Unsigned + Array<T>, <N as Array<T>>::Array: 'a,

Source§

type Output = &'a <N as Array<T>>::Array

Source§

impl<'a, T, N> GetIndex<'a, &'a [T; 12]> for StaticRange<N>
where N: Unsigned + Array<T>, <N as Array<T>>::Array: 'a,

Source§

type Output = &'a <N as Array<T>>::Array

Source§

impl<'a, T, N> GetIndex<'a, &'a [T; 13]> for StaticRange<N>
where N: Unsigned + Array<T>, <N as Array<T>>::Array: 'a,

Source§

type Output = &'a <N as Array<T>>::Array

Source§

impl<'a, T, N> GetIndex<'a, &'a [T; 14]> for StaticRange<N>
where N: Unsigned + Array<T>, <N as Array<T>>::Array: 'a,

Source§

type Output = &'a <N as Array<T>>::Array

Source§

impl<'a, T, N> GetIndex<'a, &'a [T; 15]> for StaticRange<N>
where N: Unsigned + Array<T>, <N as Array<T>>::Array: 'a,

Source§

type Output = &'a <N as Array<T>>::Array

Source§

impl<'a, T, N> GetIndex<'a, &'a [T; 16]> for StaticRange<N>
where N: Unsigned + Array<T>, <N as Array<T>>::Array: 'a,

Source§

type Output = &'a <N as Array<T>>::Array

Source§

impl<'a, T, N> GetIndex<'a, &'a [T]> for StaticRange<N>
where N: Unsigned + Array<T>, <N as Array<T>>::Array: 'a,

Source§

type Output = &'a <N as Array<T>>::Array