Struct flatcontainer::impls::columns::ColumnsRegion
source · pub struct ColumnsRegion<R, Idx>{ /* private fields */ }
Expand description
A region that can store a variable number of elements per row.
The region is backed by a number of columns, where the number depends on the length of the longest row encountered. For pushed row, the region remembers the indices into each column that populated. Rows can have different lengths, which means that only the first columns will contain a value.
All columns have the same type R
.
§Examples
Copy a table-like structure:
let data = [
vec![],
vec!["1"],
vec!["2", "3"],
vec!["4", "5", "6"],
vec!["7", "8"],
vec!["9"],
vec![],
];
let mut r = <ColumnsRegion<ConsecutiveOffsetPairs<StringRegion>, _>>::default();
let mut indices = Vec::with_capacity(data.len());
for row in &data {
let index = row.copy_onto(&mut r);
indices.push(index);
}
for (&index, row) in indices.iter().zip(&data) {
assert!(row.iter().copied().eq(r.index(index).iter()));
}
Trait Implementations§
source§impl<'a, R, Idx, T> CopyOnto<ColumnsRegion<R, Idx>> for &'a [T]
impl<'a, R, Idx, T> CopyOnto<ColumnsRegion<R, Idx>> for &'a [T]
source§fn copy_onto(
self,
target: &mut ColumnsRegion<R, Idx>
) -> <ColumnsRegion<R, Idx> as Region>::Index
fn copy_onto( self, target: &mut ColumnsRegion<R, Idx> ) -> <ColumnsRegion<R, Idx> as Region>::Index
Copy self into the target container, returning an index that allows to
look up the corresponding read item.
source§impl<'a, R, Idx, T> CopyOnto<ColumnsRegion<R, Idx>> for &'a Vec<T>
impl<'a, R, Idx, T> CopyOnto<ColumnsRegion<R, Idx>> for &'a Vec<T>
source§fn copy_onto(
self,
target: &mut ColumnsRegion<R, Idx>
) -> <ColumnsRegion<R, Idx> as Region>::Index
fn copy_onto( self, target: &mut ColumnsRegion<R, Idx> ) -> <ColumnsRegion<R, Idx> as Region>::Index
Copy self into the target container, returning an index that allows to
look up the corresponding read item.
source§impl<R, Idx, T, I> CopyOnto<ColumnsRegion<R, Idx>> for CopyIter<I>
impl<R, Idx, T, I> CopyOnto<ColumnsRegion<R, Idx>> for CopyIter<I>
source§fn copy_onto(
self,
target: &mut ColumnsRegion<R, Idx>
) -> <ColumnsRegion<R, Idx> as Region>::Index
fn copy_onto( self, target: &mut ColumnsRegion<R, Idx> ) -> <ColumnsRegion<R, Idx> as Region>::Index
Copy self into the target container, returning an index that allows to
look up the corresponding read item.
source§impl<'a, R, Idx> CopyOnto<ColumnsRegion<R, Idx>> for ReadColumns<'a, R, Idx>
impl<'a, R, Idx> CopyOnto<ColumnsRegion<R, Idx>> for ReadColumns<'a, R, Idx>
source§fn copy_onto(
self,
target: &mut ColumnsRegion<R, Idx>
) -> <ColumnsRegion<R, Idx> as Region>::Index
fn copy_onto( self, target: &mut ColumnsRegion<R, Idx> ) -> <ColumnsRegion<R, Idx> as Region>::Index
Copy self into the target container, returning an index that allows to
look up the corresponding read item.
source§impl<R, Idx, T> CopyOnto<ColumnsRegion<R, Idx>> for Vec<T>
impl<R, Idx, T> CopyOnto<ColumnsRegion<R, Idx>> for Vec<T>
source§fn copy_onto(
self,
target: &mut ColumnsRegion<R, Idx>
) -> <ColumnsRegion<R, Idx> as Region>::Index
fn copy_onto( self, target: &mut ColumnsRegion<R, Idx> ) -> <ColumnsRegion<R, Idx> as Region>::Index
Copy self into the target container, returning an index that allows to
look up the corresponding read item.
source§impl<R, Idx> Debug for ColumnsRegion<R, Idx>
impl<R, Idx> Debug for ColumnsRegion<R, Idx>
source§impl<R, Idx> Default for ColumnsRegion<R, Idx>
impl<R, Idx> Default for ColumnsRegion<R, Idx>
source§impl<R, Idx> Region for ColumnsRegion<R, Idx>
impl<R, Idx> Region for ColumnsRegion<R, Idx>
§type ReadItem<'a> = ReadColumns<'a, R, Idx>
where
Self: 'a
type ReadItem<'a> = ReadColumns<'a, R, Idx> where Self: 'a
The type of the data that one gets out of the container.
§type Index = usize
type Index = usize
The type to index into the container. Should be treated
as an opaque type, even if known.
source§fn merge_regions<'a>(regions: impl Iterator<Item = &'a Self> + Clone) -> Selfwhere
Self: 'a,
fn merge_regions<'a>(regions: impl Iterator<Item = &'a Self> + Clone) -> Selfwhere
Self: 'a,
Construct a region that can absorb the contents of
regions
in the future.source§fn index(&self, index: Self::Index) -> Self::ReadItem<'_>
fn index(&self, index: Self::Index) -> Self::ReadItem<'_>
Index into the container. The index must be obtained by
pushing data into the container.
source§fn reserve_regions<'a, I>(&mut self, regions: I)
fn reserve_regions<'a, I>(&mut self, regions: I)
Ensure that the region can absorb the items of
regions
without reallocationAuto Trait Implementations§
impl<R, Idx> Freeze for ColumnsRegion<R, Idx>
impl<R, Idx> RefUnwindSafe for ColumnsRegion<R, Idx>where
R: RefUnwindSafe,
Idx: RefUnwindSafe,
impl<R, Idx> Send for ColumnsRegion<R, Idx>
impl<R, Idx> Sync for ColumnsRegion<R, Idx>
impl<R, Idx> Unpin for ColumnsRegion<R, Idx>
impl<R, Idx> UnwindSafe for ColumnsRegion<R, Idx>where
R: UnwindSafe,
Idx: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<R, O, T> CopyOnto<ConsecutiveOffsetPairs<R, O>> for T
impl<R, O, T> CopyOnto<ConsecutiveOffsetPairs<R, O>> for T
source§fn copy_onto(
self,
target: &mut ConsecutiveOffsetPairs<R, O>
) -> <ConsecutiveOffsetPairs<R, O> as Region>::Index
fn copy_onto( self, target: &mut ConsecutiveOffsetPairs<R, O> ) -> <ConsecutiveOffsetPairs<R, O> as Region>::Index
Copy self into the target container, returning an index that allows to
look up the corresponding read item.