Deque

Struct Deque 

Source
pub struct Deque<T, I: Offset> { /* private fields */ }
Expand description

Double-ended queue with stable indices

Implementations§

Source§

impl<T, I: Offset> Deque<T, I>

Source

pub fn new() -> Self

Source

pub fn with_capacity(cap: usize) -> Self

Like VecDeque::with_capacity

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn front(&self) -> Option<&T>

Source

pub fn back(&self) -> Option<&T>

Source

pub fn front_mut(&mut self) -> Option<&mut T>

Source

pub fn back_mut(&mut self) -> Option<&mut T>

Source

pub fn get(&self, i: I) -> Option<&T>

Returns the element with index i, if it is still in the deque.

Source

pub fn get_mut(&mut self, i: I) -> Option<&mut T>

Source

pub fn push_front(&mut self, e: T) -> I

Panics on index overflow.

Source

pub fn push_back(&mut self, e: T) -> I

Panics on index overflow.

Source

pub fn pop_front(&mut self) -> Option<T>

Panics on index overflow.

Source

pub fn pop_back(&mut self) -> Option<T>

Panics on index overflow.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn iter(&self) -> Iter<'_, T, I>

Returns a (front-to-back) iterator.

Source

pub fn iter_mut(&mut self) -> IterMut<'_, T, I>

Returns a (front-to-back) iterator which returns mutable references.

Source

pub fn counter(&self) -> &I

I is how many more times pop_front has been called than push_back.

Source

pub fn counter_mut(&mut self) -> &mut I

Modifying this invalidates all indices.

Source

pub fn inner(&self) -> &VecDeque<T>

Allos access to the VecDeque inside this Deque

Source

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.

Source

pub fn into_parts(self) -> (I, VecDeque<T>)

Source

pub fn from_parts(advanced: I, v: VecDeque<T>) -> Self

Source

pub fn as_parts(&self) -> (&I, &VecDeque<T>)

Source

pub fn as_mut_parts(&mut self) -> (&mut I, &mut VecDeque<T>)

Modifying the parts inconsistently will invalidate indices.

Trait Implementations§

Source§

impl<T: Clone, I: Clone + Offset> Clone for Deque<T, I>

Source§

fn clone(&self) -> Deque<T, I>

Returns a duplicate 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, I: Debug + Offset> Debug for Deque<T, I>

Source§

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

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

impl<T, I: Offset> Default for Deque<T, I>

Source§

fn default() -> Self

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

impl<T, I: Offset> Extend<T> for Deque<T, I>

Source§

fn extend<X>(&mut self, iter: X)
where X: IntoIterator<Item = T>,

Extends a collection with the contents of an iterator. Read more
Source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Source§

impl<T, I: Offset> FromIterator<T> for Deque<T, I>

Source§

fn from_iter<X>(iter: X) -> Self
where X: IntoIterator<Item = T>,

Creates a value from an iterator. Read more
Source§

impl<T: Hash, I: Hash + Offset> Hash for Deque<T, I>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<T, I: Offset> Index<I> for Deque<T, I>

Source§

type Output = T

The returned type after indexing.
Source§

fn index(&self, i: I) -> &T

Performs the indexing (container[index]) operation. Read more
Source§

impl<T, I: Offset> IndexMut<I> for Deque<T, I>

Source§

fn index_mut(&mut self, i: I) -> &mut T

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<'v, T, I: Offset> IntoIterator for &'v Deque<T, I>

Source§

type Item = (I, &'v T)

The type of the elements being iterated over.
Source§

type IntoIter = Iter<'v, T, I>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Iter<'v, T, I>

Creates an iterator from a value. Read more
Source§

impl<'v, T, I: Offset> IntoIterator for &'v mut Deque<T, I>

Source§

type Item = (I, &'v mut T)

The type of the elements being iterated over.
Source§

type IntoIter = IterMut<'v, T, I>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> IterMut<'v, T, I>

Creates an iterator from a value. Read more
Source§

impl<T, I: Offset> IntoIterator for Deque<T, I>

Source§

type Item = (I, T)

The type of the elements being iterated over.
Source§

type IntoIter = IntoIter<T, I>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> IntoIter<T, I>

Creates an iterator from a value. Read more
Source§

impl<T: PartialEq, I: PartialEq + Offset> PartialEq for Deque<T, I>

Source§

fn eq(&self, other: &Deque<T, I>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T: Eq, I: Eq + Offset> Eq for Deque<T, I>

Source§

impl<T, I: Offset> StructuralPartialEq for Deque<T, I>

Auto Trait Implementations§

§

impl<T, I> Freeze for Deque<T, I>
where I: Freeze,

§

impl<T, I> RefUnwindSafe for Deque<T, I>

§

impl<T, I> Send for Deque<T, I>
where I: Send, T: Send,

§

impl<T, I> Sync for Deque<T, I>
where I: Sync, T: Sync,

§

impl<T, I> Unpin for Deque<T, I>
where I: Unpin, T: Unpin,

§

impl<T, I> UnwindSafe for Deque<T, I>
where I: UnwindSafe, 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> 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<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
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> ToOwned for T
where T: Clone,

Source§

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>,

Source§

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>,

Source§

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.