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 Scalar
s).
Implementations§
source§impl<T> FlatVecDeque<T>
impl<T> FlatVecDeque<T>
pub const fn new() -> Self
pub fn from_vecs(entries: impl IntoIterator<Item = Vec<T>>) -> Self
sourcepub fn num_entries(&self) -> usize
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.
sourcepub fn num_values(&self) -> usize
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>
impl<T> FlatVecDeque<T>
source§impl<T> FlatVecDeque<T>
impl<T> FlatVecDeque<T>
sourcepub fn push_front(&mut self, values: impl IntoIterator<Item = T>)
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.
sourcepub fn push_back(&mut self, values: impl IntoIterator<Item = T>)
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.
sourcepub fn insert(
&mut self,
entry_index: usize,
values: impl IntoIterator<Item = T>
)
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.
sourcepub fn push_many_front(&mut self, entries: impl IntoIterator<Item = Vec<T>>)
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.
sourcepub fn push_many_back(&mut self, entries: impl IntoIterator<Item = Vec<T>>)
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.
sourcepub fn insert_many(
&mut self,
entry_index: usize,
entries: impl IntoIterator<Item = Vec<T>>
)
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.
sourcepub fn push_front_deque(&mut self, rhs: FlatVecDeque<T>)
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.
sourcepub fn push_back_deque(&mut self, rhs: FlatVecDeque<T>)
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.
sourcepub fn insert_deque(&mut self, entry_index: usize, rhs: FlatVecDeque<T>)
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>
impl<T> FlatVecDeque<T>
sourcepub fn split_off(&mut self, entry_index: usize) -> Self
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.
sourcepub fn truncate(&mut self, entry_index: usize)
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.
sourcepub fn remove(&mut self, entry_index: usize)
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.
sourcepub fn remove_range(&mut self, entry_range: Range<usize>)
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>
impl<T: Clone> Clone for FlatVecDeque<T>
source§fn clone(&self) -> FlatVecDeque<T>
fn clone(&self) -> FlatVecDeque<T>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<T: Debug> Debug for FlatVecDeque<T>
impl<T: Debug> Debug for FlatVecDeque<T>
source§impl<T> Default for FlatVecDeque<T>
impl<T> Default for FlatVecDeque<T>
source§impl<T> ErasedFlatVecDeque for FlatVecDeque<T>
impl<T> ErasedFlatVecDeque for FlatVecDeque<T>
fn as_any(&self) -> &dyn Any
fn as_any_mut(&mut self) -> &mut dyn Any
source§fn dyn_clone(&self) -> Box<dyn ErasedFlatVecDeque + Send + Sync>
fn dyn_clone(&self) -> Box<dyn ErasedFlatVecDeque + Send + Sync>
FlatVecDeque::clone
. Read morefn into_any(self: Box<Self>) -> Box<dyn Any>
source§fn dyn_num_entries(&self) -> usize
fn dyn_num_entries(&self) -> usize
FlatVecDeque::num_entries
. Read moresource§fn dyn_num_values(&self) -> usize
fn dyn_num_values(&self) -> usize
FlatVecDeque::num_values
. Read moresource§fn dyn_remove(&mut self, at: usize)
fn dyn_remove(&mut self, at: usize)
FlatVecDeque::remove
. Read moresource§fn dyn_remove_range(&mut self, range: Range<usize>)
fn dyn_remove_range(&mut self, range: Range<usize>)
FlatVecDeque::remove
. Read moresource§fn dyn_truncate(&mut self, at: usize)
fn dyn_truncate(&mut self, at: usize)
FlatVecDeque::truncate
. Read moresource§fn dyn_total_size_bytes(&self) -> u64
fn dyn_total_size_bytes(&self) -> u64
<FlatVecDeque<T> as SizeBytes>::total_size_bytes(self)
]. Read moresource§impl<T> From<Vec<T>> for FlatVecDeque<T>
impl<T> From<Vec<T>> for FlatVecDeque<T>
source§impl<T> From<VecDeque<T>> for FlatVecDeque<T>
impl<T> From<VecDeque<T>> for FlatVecDeque<T>
source§impl<T: SizeBytes> SizeBytes for FlatVecDeque<T>
impl<T: SizeBytes> SizeBytes for FlatVecDeque<T>
source§fn heap_size_bytes(&self) -> u64
fn heap_size_bytes(&self) -> u64
self
on the heap, in bytes.source§fn total_size_bytes(&self) -> u64
fn total_size_bytes(&self) -> u64
self
in bytes, accounting for both stack and heap space.source§fn stack_size_bytes(&self) -> u64
fn stack_size_bytes(&self) -> u64
self
on the stack, in bytes. Read moreAuto 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> 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
source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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