Struct flatk::ClumpedOffsets [−][src]
A collection of clumped offsets into another collection.
A version of Offsets
that combines consecutive equidistant offsets.
Example
To see the correspondence between Offsets
and ClumpedOffsets
, consider the following
example
use flatk::{Offsets, ClumpedOffsets}; // with `Offsets` we might have offsets like let off = Offsets::new(vec![0, 3, 6, 9, 12, 16, 20, 24, 27, 30, 33, 36, 39]); // which can be represented in `ClumpedOffsets` as let clumped_off = ClumpedOffsets::new(vec![0, 4, 7, 12], vec![0, 12, 24, 39]); // Note that ClumpedOffsets would be more compact if the triplets could be combined, // which would require reorganizing the data indexed by the offsets. assert_eq!(ClumpedOffsets::from(off), clumped_off);
ClumpedOffsets
can be a lot more memory efficient when a chunked collection is mostly
uniformly chunked. However, in the worst case, when each consecutive stride is different, this
representation can be three times the size of standard Offsets
.
Fields
chunk_offsets: Offsets<O>
offsets: Offsets<O>
Implementations
impl<O: AsRef<[usize]>> ClumpedOffsets<O>
[src]
pub fn double_ended_sizes(&self) -> DEUnclumpedSizes<'_>
[src]
An iterator over effective (unclumped) sizes that implements DoubleEndedIterator
.
Notes
This iterator is used to implement the parallel sizes iterator to enable parallel iteration
of Chunked
types with clumped offsets. However, this iterator can also be used as is for
efficient backwards iteration.
pub fn par_offset_values_and_sizes(
&self
) -> ParUnclumpedOffsetValuesAndSizes<'_>
[src]
&self
) -> ParUnclumpedOffsetValuesAndSizes<'_>
Parallel version of offsets_and_sizes
.
impl<O: AsRef<[usize]>> ClumpedOffsets<O>
[src]
pub fn first_chunk_offset_value(&self) -> usize
[src]
pub fn last_chunk_offset_value(&self) -> usize
[src]
pub fn num_clump_offsets(&self) -> usize
[src]
Returns the number of clump offsets represented by ClumpedOffsets
.
This is typically significantly smaller than self.num_offsets()
.
pub fn num_clumps(&self) -> usize
[src]
Returns the number of clumps represented by ClumpedOffsets
.
pub fn clump_stride(&self, index: usize) -> usize
[src]
Compute the stride of the clump at the given index.
Panics
This function panics if index
is greater than or equal to self.num_clumps()
.
impl<O: AsRef<[usize]>> ClumpedOffsets<O>
[src]
pub fn sizes(&self) -> UnclumpedSizes<'_>ⓘNotable traits for UnclumpedSizes<'a>
impl<'a> Iterator for UnclumpedSizes<'a> type Item = usize;
[src]
Notable traits for UnclumpedSizes<'a>
impl<'a> Iterator for UnclumpedSizes<'a> type Item = usize;
An iterator over effective (unclumped) sizes producing an increment for advancing the data pointer.
This helps for implementing iterators over Chunked
types.
Example
use flatk::{Offsets, ClumpedOffsets}; let off = Offsets::new(vec![0, 3, 6, 9, 12, 16, 20, 24, 27, 30, 33, 36, 39]); let clumped = ClumpedOffsets::from(off); let mut clumped_iter = clumped.sizes(); for _ in 0..4 { assert_eq!(clumped_iter.next(), Some(3)); } for _ in 0..3 { assert_eq!(clumped_iter.next(), Some(4)); } for _ in 0..5 { assert_eq!(clumped_iter.next(), Some(3)); } assert_eq!(clumped_iter.next(), None);
pub fn iter<'a>(&'a self) -> impl Iterator<Item = usize> + 'a
[src]
An iterator over unclumped offsets.
This is equivalent to iterating over Offsets
after conversion, but it doesn't require any
additional allocations.
pub fn values(&self) -> UnclumpedOffsetValues<'_>ⓘNotable traits for UnclumpedOffsetValues<'a>
impl<'a> Iterator for UnclumpedOffsetValues<'a> type Item = usize;
[src]
Notable traits for UnclumpedOffsetValues<'a>
impl<'a> Iterator for UnclumpedOffsetValues<'a> type Item = usize;
An iterator over unclumped offsets.
This is equivalent to iterating over Offsets
after conversion, but it doesn't require any
additional allocations.
impl<O: AsRef<[usize]>> ClumpedOffsets<O>
[src]
pub fn new(chunk_offsets: O, offsets: O) -> Self
[src]
Construct new ClumpedOffsets
from a given valid set of clumped offsets represented as an
array of usize
s.
It is possible to create an invalid ClumpedOffsets
struct using this constructor, however
it is safe.
Panics
This function will panic if either chunk_offsets
or offsets
is empty.
pub unsafe fn from_raw(chunk_offsets: O, offsets: O) -> Self
[src]
An unchecked version of the new
constructor.
Safety
Calling this function with empty chunk_offsets
or offsets
may cause undefined behaviour
in safe APIs.
Trait Implementations
impl Clear for ClumpedOffsets
[src]
impl<O: Clone> Clone for ClumpedOffsets<O>
[src]
fn clone(&self) -> ClumpedOffsets<O>
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<O: Copy> Copy for ClumpedOffsets<O>
[src]
impl<O: Debug> Debug for ClumpedOffsets<O>
[src]
impl Default for ClumpedOffsets<Vec<usize>>
[src]
A default set of offsets must allocate.
impl<O: Dummy> Dummy for ClumpedOffsets<O>
[src]
A dummy set of offsets will not allocate, but the resulting type does not correspond to valid offsets.
unsafe fn dummy() -> Self
[src]
This function creates an invalid ClumpedOffsets
, but it does not allocate.
impl<O: AsRef<[usize]> + Set> From<ClumpedOffsets<O>> for Offsets
[src]
fn from(clumped_offsets: ClumpedOffsets<O>) -> Self
[src]
Convert ClumpedOffsets
into owned Offsets
.
This function causes allocations.
impl<O: AsRef<[usize]> + Set> From<Offsets<O>> for ClumpedOffsets
[src]
fn from(offsets: Offsets<O>) -> Self
[src]
Convert Offsets
to owned ClumpedOffsets
.
This function causes allocations.
Example
use flatk::{Offsets, ClumpedOffsets}; let offsets = Offsets::new(vec![0, 3, 6, 9, 12, 16, 20, 24, 27, 30, 33, 36, 39]); let clumped_offsets = ClumpedOffsets::new(vec![0, 4, 7, 12], vec![0, 12, 24, 39]); assert_eq!(ClumpedOffsets::from(offsets), clumped_offsets);
impl FromIterator<usize> for ClumpedOffsets
[src]
fn from_iter<T>(iter: T) -> Self where
T: IntoIterator<Item = usize>,
[src]
T: IntoIterator<Item = usize>,
impl<'a, O> GetIndex<'a, ClumpedOffsets<O>> for usize where
ClumpedOffsets<O>: GetOffset,
[src]
ClumpedOffsets<O>: GetOffset,
impl<'a, O> GetIndex<'a, ClumpedOffsets<O>> for &usize where
ClumpedOffsets<O>: GetOffset,
[src]
ClumpedOffsets<O>: GetOffset,
impl<O: AsRef<[usize]>> GetOffset for ClumpedOffsets<O>
[src]
unsafe fn offset_value_unchecked(&self, index: usize) -> usize
[src]
A version of offset_value
without bounds checking.
Safety
It is assumed that index
is strictly less than self.num_offsets()
.
fn num_offsets(&self) -> usize
[src]
Get the total number of offsets.
This is one more than the number of chunks represented.
fn chunk_len(&self, chunk_index: usize) -> usize
[src]
unsafe fn chunk_len_unchecked(&self, chunk_index: usize) -> usize
[src]
fn offset_value(&self, index: usize) -> usize
[src]
fn offset(&self, index: usize) -> usize
[src]
unsafe fn offset_unchecked(&self, index: usize) -> usize
[src]
fn last_offset(&self) -> usize
[src]
fn first_offset(&self) -> usize
[src]
fn last_offset_value(&self) -> usize
[src]
fn first_offset_value(&self) -> usize
[src]
impl<O> IndexRange for ClumpedOffsets<O> where
Self: GetOffset,
[src]
Self: GetOffset,
unsafe fn index_range_unchecked(&self, range: Range<usize>) -> Range<usize>
[src]
fn index_range(&self, range: Range<usize>) -> Option<Range<usize>>
[src]
Return the [begin..end)
bound of the chunk at the given index.
impl<'a> IntoOffsetValuesAndSizes for ClumpedOffsets<&'a [usize]>
[src]
type Iter = UnclumpedOffsetValuesAndSizes<'a>
fn into_offset_values_and_sizes(self) -> UnclumpedOffsetValuesAndSizes<'a>ⓘNotable traits for UnclumpedOffsetValuesAndSizes<'a>
impl<'a> Iterator for UnclumpedOffsetValuesAndSizes<'a> type Item = (usize, usize);
[src]
Notable traits for UnclumpedOffsetValuesAndSizes<'a>
impl<'a> Iterator for UnclumpedOffsetValuesAndSizes<'a> type Item = (usize, usize);
impl<O: IntoOwned> IntoOwned for ClumpedOffsets<O>
[src]
type Owned = ClumpedOffsets<O::Owned>
fn into_owned(self) -> Self::Owned
[src]
fn clone_into(self, target: &mut Self::Owned)
[src]
impl<'a> IntoParOffsetValuesAndSizes for ClumpedOffsets<&'a [usize]>
[src]
type ParIter = ParUnclumpedOffsetValuesAndSizes<'a>
fn into_par_offset_values_and_sizes(self) -> Self::ParIter
[src]
Returns a parallel iterator over chunk offsets and sizes represented by the stored Offsets
.
impl<'a> IntoSizes for ClumpedOffsets<&'a [usize]>
[src]
type Iter = UnclumpedSizes<'a>
fn into_sizes(self) -> UnclumpedSizes<'a>ⓘNotable traits for UnclumpedSizes<'a>
impl<'a> Iterator for UnclumpedSizes<'a> type Item = usize;
[src]
Notable traits for UnclumpedSizes<'a>
impl<'a> Iterator for UnclumpedSizes<'a> type Item = usize;
Returns an iterator over chunk sizes represented by the stored ClumpedOffsets
.
impl<'a> IntoValues for ClumpedOffsets<&'a [usize]>
[src]
type Iter = UnclumpedOffsetValues<'a>
fn into_values(self) -> UnclumpedOffsetValues<'a>ⓘNotable traits for UnclumpedOffsetValues<'a>
impl<'a> Iterator for UnclumpedOffsetValues<'a> type Item = usize;
[src]
Notable traits for UnclumpedOffsetValues<'a>
impl<'a> Iterator for UnclumpedOffsetValues<'a> type Item = usize;
Returns an iterator over offset values represented by the stored Offsets
.
impl<O> IsolateIndex<ClumpedOffsets<O>> for usize where
ClumpedOffsets<O>: GetOffset,
[src]
ClumpedOffsets<O>: GetOffset,
type Output = usize
unsafe fn isolate_unchecked(
self,
clumped_offsets: ClumpedOffsets<O>
) -> Self::Output
[src]
self,
clumped_offsets: ClumpedOffsets<O>
) -> Self::Output
fn try_isolate(self, clumped_offsets: ClumpedOffsets<O>) -> Option<Self::Output>
[src]
impl<O: PartialEq> PartialEq<ClumpedOffsets<O>> for ClumpedOffsets<O>
[src]
fn eq(&self, other: &ClumpedOffsets<O>) -> bool
[src]
fn ne(&self, other: &ClumpedOffsets<O>) -> bool
[src]
impl<O: RemovePrefix + Set> RemovePrefix for ClumpedOffsets<O>
[src]
fn remove_prefix(&mut self, n: usize)
[src]
impl<O: Reserve> Reserve for ClumpedOffsets<O>
[src]
fn reserve_with_storage(&mut self, n: usize, storage_n: usize)
[src]
fn reserve(&mut self, n: usize)
[src]
impl<O: AsRef<[usize]>> Set for ClumpedOffsets<O>
[src]
type Elem = usize
Owned element of the set.
type Atom = usize
The most basic element contained by this collection.
If this collection contains other collections, this type should be
different than Elem
. Read more
fn len(&self) -> usize
[src]
fn is_empty(&self) -> bool
[src]
impl<'a> SplitOffsetsAt for ClumpedOffsets<&'a [usize]>
[src]
fn split_offsets_with_intersection_at(
self,
mid_off: usize
) -> (ClumpedOffsets<&'a [usize]>, ClumpedOffsets<&'a [usize]>, usize)
[src]
self,
mid_off: usize
) -> (ClumpedOffsets<&'a [usize]>, ClumpedOffsets<&'a [usize]>, usize)
Same as split_offsets_at
, but in addition, return the offset of the middle element
(intersection): this is the value offsets[mid] - offsets[0]
.
Panics
Calling this function with an empty slice or with mid
greater than or equal to its length
will cause a panic.
This function will also panic when trying to split a clump since the offsets cannot be modified or created.
fn split_offsets_at(
self,
mid: usize
) -> (ClumpedOffsets<&'a [usize]>, ClumpedOffsets<&'a [usize]>)
[src]
self,
mid: usize
) -> (ClumpedOffsets<&'a [usize]>, ClumpedOffsets<&'a [usize]>)
Splits clumped offsets at the given index into two such that each
resulting ClumpedOffsets
is valid. This means that the element at index
mid
is shared between the two outputs.
Panics
Calling this function with an empty slice or with mid
greater than or equal to its length
will cause a panic.
This function will also panic when trying to split a clump since the offsets cannot be modified or created.
impl<O> StructuralPartialEq for ClumpedOffsets<O>
[src]
impl<O: Truncate> Truncate for ClumpedOffsets<O>
[src]
impl<'a, O: AsRef<[usize]>> View<'a> for ClumpedOffsets<O>
[src]
impl<'a, O: AsMut<[usize]>> ViewMut<'a> for ClumpedOffsets<O>
[src]
impl<O: Viewed> Viewed for ClumpedOffsets<O>
[src]
Auto Trait Implementations
impl<O> RefUnwindSafe for ClumpedOffsets<O> where
O: RefUnwindSafe,
[src]
O: RefUnwindSafe,
impl<O> Send for ClumpedOffsets<O> where
O: Send,
[src]
O: Send,
impl<O> Sync for ClumpedOffsets<O> where
O: Sync,
[src]
O: Sync,
impl<O> Unpin for ClumpedOffsets<O> where
O: Unpin,
[src]
O: Unpin,
impl<O> UnwindSafe for ClumpedOffsets<O> where
O: UnwindSafe,
[src]
O: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> AsSlice<T> for T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<'a, S, I> Get<'a, I> for S where
I: GetIndex<'a, S>,
[src]
I: GetIndex<'a, S>,
type Output = <I as GetIndex<'a, S>>::Output
pub fn get(&Self, I) -> Option<<I as GetIndex<'a, S>>::Output>
[src]
fn at(&self, idx: I) -> Self::Output
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<S, I> Isolate<I> for S where
I: IsolateIndex<S>,
[src]
I: IsolateIndex<S>,
type Output = <I as IsolateIndex<S>>::Output
pub unsafe fn isolate_unchecked(Self, I) -> <S as Isolate<I>>::Output
[src]
pub fn try_isolate(Self, I) -> Option<<S as Isolate<I>>::Output>
[src]
fn isolate(self, idx: I) -> Self::Output where
Self: Sized,
[src]
Self: Sized,
impl<T> Pointable for T
pub const ALIGN: usize
type Init = T
The type for initializers.
pub unsafe fn init(init: <T as Pointable>::Init) -> usize
pub unsafe fn deref<'a>(ptr: usize) -> &'a T
pub unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T
pub unsafe fn drop(ptr: usize)
impl<T> Same<T> for T
[src]
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,