Struct stack_graphs::arena::Deque [−][src]
#[repr(C)]pub struct Deque<T> { /* fields omitted */ }
Expand description
An arena-allocated deque.
Under the covers, this is implemented as a List
. Because these lists are singly-linked,
we can only add elements to, and remove them from, one side of the list.
To handle this, each deque stores its contents either forwards or backwards. We automatically shift between these two representations as needed, depending on the requirements of each method.
Note that we cache the result of reversing the list, so it should be quick to switch back and forth between representations as long as you have not added any additional elements to the deque! If performance is critical, you should ensure that you don’t call methods in a pattern that causes the deque to reverse itself each time you add an element.
Implementations
Creates a new DequeArena
that will manage deques of this type.
pub fn iter_unordered<'a>(
&self,
arena: &'a DequeArena<T>
) -> impl Iterator<Item = &'a T> + 'a
pub fn iter_unordered<'a>(
&self,
arena: &'a DequeArena<T>
) -> impl Iterator<Item = &'a T> + 'a
Returns an iterator over the contents of this deque, with no guarantee about the ordering of the elements. (By not caring about the ordering of the elements, you can call this method regardless of which direction the deque’s elements are currently stored. And that, in turn, means that we only need shared access to the arena, and not mutable access to it.)
Ensures that this deque has computed its backwards-facing list of elements.
Ensures that this deque has computed its forwards-facing list of elements.
Pushes a new element onto the front of this deque.
Pushes a new element onto the back of this deque.
Removes and returns the element from the front of this deque. If the deque is empty,
returns None
.
Removes and returns the element from the back of this deque. If the deque is empty,
returns None
.
Returns an iterator over the contents of this deque in a forwards direction.
pub fn iter_reversed<'a>(
&self,
arena: &'a mut DequeArena<T>
) -> impl Iterator<Item = &'a T> + 'a
pub fn iter_reversed<'a>(
&self,
arena: &'a mut DequeArena<T>
) -> impl Iterator<Item = &'a T> + 'a
Returns an iterator over the contents of this deque in a backwards direction.
Returns an iterator over the contents of this deque in a forwards direction, assuming that
we have already computed its forwards-facing list of elements via ensure_forwards
.
Panics if we haven’t already computed it.
pub fn iter_reversed_reused<'a>(
&self,
arena: &'a DequeArena<T>
) -> impl Iterator<Item = &'a T> + 'a
pub fn iter_reversed_reused<'a>(
&self,
arena: &'a DequeArena<T>
) -> impl Iterator<Item = &'a T> + 'a
Returns an iterator over the contents of this deque in a backwards direction, assuming that
we have already computed its backwards-facing list of elements via ensure_backwards
.
Panics if we haven’t already computed it.
Trait Implementations
Auto Trait Implementations
impl<T> !RefUnwindSafe for Deque<T>
impl<T> UnwindSafe for Deque<T> where
T: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more