Trait rerun::external::re_log_types::VecDequeRemovalExt

source ·
pub trait VecDequeRemovalExt<T> {
    // Required methods
    fn swap_remove(&mut self, index: usize) -> Option<T>;
    fn split_off_or_default(&mut self, at: usize) -> Self;
    fn remove_range(&mut self, range: Range<usize>);
}
Expand description

Extends VecDeque with extra removal routines.

Required Methods§

source

fn swap_remove(&mut self, index: usize) -> Option<T>

Removes an element from anywhere in the deque and returns it, replacing it with whichever end element that this is closer to the removal point.

If index points to the front or back of the queue, the removal is guaranteed to preserve ordering; otherwise it doesn’t. In either case, this is O(1).

Returns None if index is out of bounds.

source

fn split_off_or_default(&mut self, at: usize) -> Self

Splits the deque into two at the given index.

Returns a newly allocated VecDeque. self contains elements [0, at), and the returned deque contains elements [at, len).

If at is equal or greater than the length, the returned VecDeque is empty.

Note that the capacity of self does not change.

source

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

Removes and returns the elements in the given range from the deque.

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

This doesn’t do any kind of element re-ordering: if the deque was sorted before, it’s still sorted after.

Panics if index is out of bounds.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl<T> VecDequeRemovalExt<T> for VecDeque<T>
where T: Clone,

source§

fn swap_remove(&mut self, index: usize) -> Option<T>

source§

fn split_off_or_default(&mut self, at: usize) -> VecDeque<T>

source§

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

Implementors§