pub struct Deque<T> { /* private fields */ }Expand description
A deque stores multiple items at the given key. It provides efficient FIFO and LIFO access, as well as direct index access.
It has a maximum capacity of u32::MAX - 1. Make sure to never exceed that number when using this type.
If you do, the methods won’t work as intended anymore.
Implementations§
Source§impl<T> Deque<T>
impl<T> Deque<T>
Source§impl<T: Serialize + DeserializeOwned> Deque<T>
impl<T: Serialize + DeserializeOwned> Deque<T>
Sourcepub fn push_back(&self, storage: &mut dyn Storage, value: &T) -> StdResult<()>
pub fn push_back(&self, storage: &mut dyn Storage, value: &T) -> StdResult<()>
Adds the given value to the end of the deque
Sourcepub fn push_front(&self, storage: &mut dyn Storage, value: &T) -> StdResult<()>
pub fn push_front(&self, storage: &mut dyn Storage, value: &T) -> StdResult<()>
Adds the given value to the front of the deque
Sourcepub fn pop_back(&self, storage: &mut dyn Storage) -> StdResult<Option<T>>
pub fn pop_back(&self, storage: &mut dyn Storage) -> StdResult<Option<T>>
Removes the last element of the deque and returns it
Sourcepub fn pop_front(&self, storage: &mut dyn Storage) -> StdResult<Option<T>>
pub fn pop_front(&self, storage: &mut dyn Storage) -> StdResult<Option<T>>
Removes the first element of the deque and returns it
Sourcepub fn front(&self, storage: &dyn Storage) -> StdResult<Option<T>>
pub fn front(&self, storage: &dyn Storage) -> StdResult<Option<T>>
Returns the first element of the deque without removing it
Sourcepub fn back(&self, storage: &dyn Storage) -> StdResult<Option<T>>
pub fn back(&self, storage: &dyn Storage) -> StdResult<Option<T>>
Returns the last element of the deque without removing it
Sourcepub fn is_empty(&self, storage: &dyn Storage) -> StdResult<bool>
pub fn is_empty(&self, storage: &dyn Storage) -> StdResult<bool>
Returns true if the deque contains no elements.
Auto Trait Implementations§
impl<T> Freeze for Deque<T>
impl<T> RefUnwindSafe for Deque<T>where
T: RefUnwindSafe,
impl<T> Send for Deque<T>where
T: Send,
impl<T> Sync for Deque<T>where
T: Sync,
impl<T> Unpin for Deque<T>where
T: Unpin,
impl<T> UnsafeUnpin for Deque<T>
impl<T> UnwindSafe for Deque<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more