pub struct Deque<T> { /* private fields */ }Expand description
Append-only deque which ensures the elements pushed into it never move. Allocates chunks in doubling capacities.
Implementations§
Source§impl<T> Deque<T>
impl<T> Deque<T>
pub fn new() -> Self
Sourcepub fn push(&mut self, val: T) -> &T
pub fn push(&mut self, val: T) -> &T
Append an element to the deque and return a reference to it. The element will not move after it is allocated.
pub fn is_empty(&self) -> bool
Sourcepub fn iter_mut(&mut self) -> impl Iterator<Item = &mut T>
pub fn iter_mut(&mut self) -> impl Iterator<Item = &mut T>
Iterator over every element of the deque.
Sourcepub fn truncate(&mut self, len: usize)
pub fn truncate(&mut self, len: usize)
Truncate the deque to len elements, dropping every element at
index >= len and freeing fully-vacated trailing chunks. Surviving
elements never move (only trailing elements/chunks are dropped), so
references to them remain valid. Used by the AST arena’s
AllocationScope (bump-allocator save/restore semantics, mirroring
the C++ BumpPtrAllocator::pushScope/popScope,
hermes/Support/Allocator.h:500).
Sourcepub fn iter_from(&self, index: usize) -> impl Iterator<Item = &T>
pub fn iter_from(&self, index: usize) -> impl Iterator<Item = &T>
Iterate over the elements starting at index. Positions by chunk
arithmetic (a handful of chunk-boundary comparisons; skipped
elements are not walked), so iterating a suffix is O(suffix).
An index at or past len() yields an empty iterator.