Struct flatcontainer::impls::columns::ColumnsRegion

source ·
pub struct ColumnsRegion<R, Idx>
where R: Region<Index = Idx>, Idx: Index,
{ /* 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]
where R: Region<Index = Idx>, Idx: Index, &'a T: CopyOnto<R>,

source§

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>
where R: Region<Index = Idx>, Idx: Index, &'a T: CopyOnto<R>,

source§

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>
where R: Region<Index = Idx>, Idx: Index, T: CopyOnto<R>, I: IntoIterator<Item = T>,

source§

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>
where R: Region<Index = Idx>, Idx: Index,

source§

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>
where R: Region<Index = Idx>, Idx: Index, T: CopyOnto<R>,

source§

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>
where R: Region<Index = Idx> + Debug, Idx: Index + Debug,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<R, Idx> Default for ColumnsRegion<R, Idx>
where R: Region<Index = Idx>, Idx: Index,

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<R, Idx> Region for ColumnsRegion<R, Idx>
where R: Region<Index = Idx>, Idx: Index,

§

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

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) -> Self
where Self: 'a,

Construct a region that can absorb the contents of regions in the future.
source§

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)
where Self: 'a, I: Iterator<Item = &'a Self> + Clone,

Ensure that the region can absorb the items of regions without reallocation
source§

fn clear(&mut self)

Remove all elements from this region, but retain allocations if possible.
source§

fn heap_size<F: FnMut(usize, usize)>(&self, callback: F)

Heap size, size - capacity

Auto Trait Implementations§

§

impl<R, Idx> Freeze for ColumnsRegion<R, Idx>

§

impl<R, Idx> RefUnwindSafe for ColumnsRegion<R, Idx>

§

impl<R, Idx> Send for ColumnsRegion<R, Idx>
where R: Send, Idx: Send,

§

impl<R, Idx> Sync for ColumnsRegion<R, Idx>
where R: Sync, Idx: Sync,

§

impl<R, Idx> Unpin for ColumnsRegion<R, Idx>
where R: Unpin, Idx: Unpin,

§

impl<R, Idx> UnwindSafe for ColumnsRegion<R, Idx>
where R: UnwindSafe, Idx: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

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
where R: Region<Index = (usize, usize)>, O: OffsetContainer<usize>, T: CopyOnto<R>,

source§

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.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.