Struct re_query::FlatVecDeque

source ·
pub struct FlatVecDeque<T> { /* private fields */ }
Expand description

A double-ended queue implemented with a pair of growable ring buffers, where every single entry is a flattened array of values.

Logically like a VecDeque<Box<[T]>>, but with a less fragmented memory layout (each Box<[T]> gets copied/inlined into the FlatVecDeque). FlatVecDeque therefore optimizes for reads (cache locality, specifically) while VecDeque<Box<[T]>> optimizes for writes.

You can think of this as the native/deserialized version of an Arrow ListArray. This is particularly useful when working with many small arrays of data (e.g. Rerun’s Scalars).

Implementations§

source§

impl<T> FlatVecDeque<T>

source

pub const fn new() -> Self

source

pub fn from_vecs(entries: impl IntoIterator<Item = Vec<T>>) -> Self

source

pub fn num_entries(&self) -> usize

How many entries are there in the deque?

Keep in mind: each entry is itself an array of values. Use Self::num_values to get the total number of values across all entries.

source

pub fn num_values(&self) -> usize

How many values are there in the deque?

Keep in mind: each entry in the deque holds an array of values. Use Self::num_entries to get the total number of entries, irrelevant of how many values each entry holds.

source§

impl<T> FlatVecDeque<T>

source

pub fn iter(&self) -> impl Iterator<Item = &[T]>

Iterates over all the entries in the deque.

This is the same as self.range(0..self.num_entries()).

Keep in mind that each entry is an array of values!

source

pub fn range(&self, entry_range: Range<usize>) -> impl Iterator<Item = &[T]>

Iterates over all the entries in the deque in the given entry_range.

Keep in mind that each entry is an array of values!

source§

impl<T> FlatVecDeque<T>

source

pub fn push_front(&mut self, values: impl IntoIterator<Item = T>)

Prepends an entry comprised of values to the deque.

This is the same as self.insert(0, values).

See Self::insert for more information.

source

pub fn push_back(&mut self, values: impl IntoIterator<Item = T>)

Appends an entry comprised of values to the deque.

This is the same as self.insert(self.num_entries(), values).

See Self::insert for more information.

source

pub fn insert( &mut self, entry_index: usize, values: impl IntoIterator<Item = T> )

Inserts a single entry at entry_index, comprised of the multiple elements given as values.

This is O(1) if entry_index corresponds to either the start or the end of the deque. Otherwise, this requires splitting the deque into two pieces then stitching them back together at both ends of the added data.

Panics if entry_index is out of bounds. Panics if values is empty.

source

pub fn push_many_front(&mut self, entries: impl IntoIterator<Item = Vec<T>>)

Prepends multiple entries, each comprised of the multiple elements given in entries, to the deque.

This is the same as self.insert_many(0, entries).

See Self::insert_many for more information.

source

pub fn push_many_back(&mut self, entries: impl IntoIterator<Item = Vec<T>>)

Appends multiple entries, each comprised of the multiple elements given in entries, to the deque.

This is the same as self.insert_many(self.num_entries(), entries).

See Self::insert_many for more information.

source

pub fn insert_many( &mut self, entry_index: usize, entries: impl IntoIterator<Item = Vec<T>> )

Inserts multiple entries, starting at entry_index onwards, each comprised of the multiple elements given in entries.

This is O(1) if entry_index corresponds to either the start or the end of the deque. Otherwise, this requires splitting the deque into two pieces then stitching them back together at both ends of the added data.

Panics if entry_index is out of bounds. Panics if any of the value arrays in entries is empty.

source

pub fn push_front_deque(&mut self, rhs: FlatVecDeque<T>)

Prepends another full deque to the deque.

This is the same as self.insert_deque(0, rhs).

See Self::insert_deque for more information.

source

pub fn push_back_deque(&mut self, rhs: FlatVecDeque<T>)

Appends another full deque to the deque.

This is the same as self.insert_deque(0, rhs).

See Self::insert_deque for more information.

source

pub fn insert_deque(&mut self, entry_index: usize, rhs: FlatVecDeque<T>)

Inserts another full deque, starting at entry_index and onwards.

This is O(1) if entry_index corresponds to either the start or the end of the deque. Otherwise, this requires splitting the deque into two pieces then stitching them back together at both ends of the added data.

Panics if entry_index is out of bounds. Panics if any of the value arrays in entries is empty.

source§

impl<T> FlatVecDeque<T>

source

pub fn split_off(&mut self, entry_index: usize) -> Self

Splits the deque into two at the given index.

Returns a newly allocated FlatVecDeque. self contains entries [0, entry_index), and the returned deque contains entries [entry_index, num_entries).

Note that the capacity of self does not change.

Panics if entry_index is out of bounds.

source

pub fn truncate(&mut self, entry_index: usize)

Shortens the deque, keeping all entries up to entry_index (excluded), and dropping the rest.

If entry_index is greater or equal to Self::num_entries, this has no effect.

source

pub fn remove(&mut self, entry_index: usize)

Removes the entry at entry_index from the deque.

This is O(1) if entry_index corresponds to either the start or the end of the deque. Otherwise, this requires splitting the deque into three pieces, dropping the superfluous one, then stitching the two remaining pices back together.

Panics if entry_index is out of bounds.

source

pub fn remove_range(&mut self, entry_range: Range<usize>)

Removes all entries within the given entry_range from the deque.

This is O(1) if entry_range either starts at the beginning of the deque, or ends at the end of the deque, or both. Otherwise, this requires splitting the deque into three pieces, dropping the superfluous one, then stitching the two remaining pieces back together.

Panics if entry_range is either out of bounds or isn’t monotonically increasing.

Trait Implementations§

source§

impl<T: Clone> Clone for FlatVecDeque<T>

source§

fn clone(&self) -> FlatVecDeque<T>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<T: Debug> Debug for FlatVecDeque<T>

source§

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

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

impl<T> Default for FlatVecDeque<T>

source§

fn default() -> Self

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

impl<T> ErasedFlatVecDeque for FlatVecDeque<T>
where T: Send + Sync + Clone + SizeBytes + 'static,

source§

fn as_any(&self) -> &dyn Any

source§

fn as_any_mut(&mut self) -> &mut dyn Any

source§

fn dyn_clone(&self) -> Box<dyn ErasedFlatVecDeque + Send + Sync>

Dynamically dispatches to FlatVecDeque::clone. Read more
source§

fn into_any(self: Box<Self>) -> Box<dyn Any>

source§

fn dyn_num_entries(&self) -> usize

Dynamically dispatches to FlatVecDeque::num_entries. Read more
source§

fn dyn_num_values(&self) -> usize

Dynamically dispatches to FlatVecDeque::num_values. Read more
source§

fn dyn_remove(&mut self, at: usize)

Dynamically dispatches to FlatVecDeque::remove. Read more
source§

fn dyn_remove_range(&mut self, range: Range<usize>)

Dynamically dispatches to FlatVecDeque::remove. Read more
source§

fn dyn_truncate(&mut self, at: usize)

Dynamically dispatches to FlatVecDeque::truncate. Read more
source§

fn dyn_total_size_bytes(&self) -> u64

Dynamically dispatches to [<FlatVecDeque<T> as SizeBytes>::total_size_bytes(self)]. Read more
source§

impl<T> From<Vec<T>> for FlatVecDeque<T>

source§

fn from(values: Vec<T>) -> Self

Converts to this type from the input type.
source§

impl<T> From<VecDeque<T>> for FlatVecDeque<T>

source§

fn from(values: VecDeque<T>) -> Self

Converts to this type from the input type.
source§

impl<T: SizeBytes> SizeBytes for FlatVecDeque<T>

source§

fn heap_size_bytes(&self) -> u64

Returns the total size of self on the heap, in bytes.
source§

fn total_size_bytes(&self) -> u64

Returns the total size of self in bytes, accounting for both stack and heap space.
source§

fn stack_size_bytes(&self) -> u64

Returns the total size of self on the stack, in bytes. Read more
source§

fn is_pod() -> bool

Is Self just plain old data? Read more

Auto Trait Implementations§

§

impl<T> Freeze for FlatVecDeque<T>

§

impl<T> RefUnwindSafe for FlatVecDeque<T>
where T: RefUnwindSafe,

§

impl<T> Send for FlatVecDeque<T>
where T: Send,

§

impl<T> Sync for FlatVecDeque<T>
where T: Sync,

§

impl<T> Unpin for FlatVecDeque<T>
where T: Unpin,

§

impl<T> UnwindSafe for FlatVecDeque<T>
where T: 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> Az for T

source§

fn az<Dst>(self) -> Dst
where T: Cast<Dst>,

Casts the value.
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<Src, Dst> CastFrom<Src> for Dst
where Src: Cast<Dst>,

source§

fn cast_from(src: Src) -> Dst

Casts the value.
source§

impl<T> CheckedAs for T

source§

fn checked_as<Dst>(self) -> Option<Dst>
where T: CheckedCast<Dst>,

Casts the value.
source§

impl<Src, Dst> CheckedCastFrom<Src> for Dst
where Src: CheckedCast<Dst>,

source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
source§

impl<T> DynClone for T
where T: Clone,

source§

fn __clone_box(&self, _: Private) -> *mut ()

source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

impl<Src, Dst> LosslessTryInto<Dst> for Src
where Dst: LosslessTryFrom<Src>,

source§

fn lossless_try_into(self) -> Option<Dst>

Performs the conversion.
source§

impl<Src, Dst> LossyInto<Dst> for Src
where Dst: LossyFrom<Src>,

source§

fn lossy_into(self) -> Dst

Performs the conversion.
source§

impl<T> OverflowingAs for T

source§

fn overflowing_as<Dst>(self) -> (Dst, bool)
where T: OverflowingCast<Dst>,

Casts the value.
source§

impl<Src, Dst> OverflowingCastFrom<Src> for Dst
where Src: OverflowingCast<Dst>,

source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
source§

impl<T> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> SaturatingAs for T

source§

fn saturating_as<Dst>(self) -> Dst
where T: SaturatingCast<Dst>,

Casts the value.
source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dst
where Src: SaturatingCast<Dst>,

source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
source§

impl<T> UnwrappedAs for T

source§

fn unwrapped_as<Dst>(self) -> Dst
where T: UnwrappedCast<Dst>,

Casts the value.
source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dst
where Src: UnwrappedCast<Dst>,

source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> WrappingAs for T

source§

fn wrapping_as<Dst>(self) -> Dst
where T: WrappingCast<Dst>,

Casts the value.
source§

impl<Src, Dst> WrappingCastFrom<Src> for Dst
where Src: WrappingCast<Dst>,

source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.