Struct vecdeque_stableix::Deque
source · pub struct Deque<T, I: Offset> { /* private fields */ }
Expand description
Double-ended queue with stable indices
Implementations
sourceimpl<T, I: Offset> Deque<T, I>
impl<T, I: Offset> Deque<T, I>
pub fn new() -> Self
sourcepub fn with_capacity(cap: usize) -> Self
pub fn with_capacity(cap: usize) -> Self
Like VecDeque::with_capacity
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn front(&self) -> Option<&T>
pub fn back(&self) -> Option<&T>
pub fn front_mut(&mut self) -> Option<&mut T>
pub fn back_mut(&mut self) -> Option<&mut T>
sourcepub fn get(&self, i: I) -> Option<&T>
pub fn get(&self, i: I) -> Option<&T>
Returns the element with index i
, if it is still in the deque.
pub fn get_mut(&mut self, i: I) -> Option<&mut T>
sourcepub fn push_front(&mut self, e: T) -> I
pub fn push_front(&mut self, e: T) -> I
Panics on index overflow.
sourcepub fn swap_remove_front(&mut self, i: I) -> Option<T>
pub fn swap_remove_front(&mut self, i: I) -> Option<T>
Removes the element with index i
, by replacing it with the
eleement from the front. Invalidates the index of the front
element element (now i
refers to that) but leaves other
indices valid. Panics on index overflow.
sourcepub fn swap_remove_back(&mut self, i: I) -> Option<T>
pub fn swap_remove_back(&mut self, i: I) -> Option<T>
Removes the element with index i
, by replacing it with the
eleement from the back. Invalidates the index of the back
element (now i
refers to that), but leaves other indices
valid. Panics on index overflow.
sourcepub fn front_index(&self) -> I
pub fn front_index(&self) -> I
The index of the first item the deque. If the queue is
empty, this is the same as end_index
.
sourcepub fn end_index(&self) -> I
pub fn end_index(&self) -> I
The index just after the end of the qeue. I.e., the index that
would be assigned to a new element added with push_back
.
Panics on index overflow.
sourcepub fn iter(&self) -> Iter<'_, T, I>ⓘNotable traits for Iter<'v, T, I>impl<'v, T, I: Offset> Iterator for Iter<'v, T, I> type Item = (I, &'v T);
pub fn iter(&self) -> Iter<'_, T, I>ⓘNotable traits for Iter<'v, T, I>impl<'v, T, I: Offset> Iterator for Iter<'v, T, I> type Item = (I, &'v T);
Returns a (front-to-back) iterator.
sourcepub fn iter_mut(&mut self) -> IterMut<'_, T, I>ⓘNotable traits for IterMut<'v, T, I>impl<'v, T, I: Offset> Iterator for IterMut<'v, T, I> type Item = (I, &'v mut T);
pub fn iter_mut(&mut self) -> IterMut<'_, T, I>ⓘNotable traits for IterMut<'v, T, I>impl<'v, T, I: Offset> Iterator for IterMut<'v, T, I> type Item = (I, &'v mut T);
Returns a (front-to-back) iterator which returns mutable references.
sourcepub fn counter_mut(&mut self) -> &mut I
pub fn counter_mut(&mut self) -> &mut I
Modifying this invalidates all indices.
sourcepub fn inner_mut(&mut self) -> &mut VecDeque<T>
pub fn inner_mut(&mut self) -> &mut VecDeque<T>
Mutable access to the VecDeque
inside this Dequeu
.
Adding/removing elements at the front of of the VecDeque
invalidates all indices.
pub fn into_parts(self) -> (I, VecDeque<T>)
pub fn from_parts(advanced: I, v: VecDeque<T>) -> Self
pub fn as_parts(&self) -> (&I, &VecDeque<T>)
sourcepub fn as_mut_parts(&mut self) -> (&mut I, &mut VecDeque<T>)
pub fn as_mut_parts(&mut self) -> (&mut I, &mut VecDeque<T>)
Modifying the parts inconsistently will invalidate indices.
Trait Implementations
sourceimpl<T, I: Offset> Extend<T> for Deque<T, I>
impl<T, I: Offset> Extend<T> for Deque<T, I>
sourcefn extend<X>(&mut self, iter: X)where
X: IntoIterator<Item = T>,
fn extend<X>(&mut self, iter: X)where
X: IntoIterator<Item = T>,
sourcefn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)sourcefn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)