pub struct QueueMapper<SA, T, A = CurrentStorage>{ /* private fields */ }
Expand description
A queue with owned nodes.
The QueueMapper
allows pushing and popping elements at either end
in constant time.
Implementations§
Source§impl<SA, T> QueueMapper<SA, T>
impl<SA, T> QueueMapper<SA, T>
Sourcepub fn push_back(&mut self, elt: T)
pub fn push_back(&mut self, elt: T)
Appends an element to the back of a queue.
This operation should compute in O(1) time.
Sourcepub fn push_front(&mut self, elt: T)
pub fn push_front(&mut self, elt: T)
Adds an element first in the queue.
This operation should compute in O(1) time.
Source§impl<SA, A, T> QueueMapper<SA, T, A>
impl<SA, A, T> QueueMapper<SA, T, A>
pub fn iter(&self) -> Iter<'_, SA, A, T>
pub fn iter_from_node_id(&self, node_id: u32) -> Iter<'_, SA, A, T>
pub fn get_node(&self, node_id: u32) -> Node
pub fn get_value_option(&self, node_id: u32) -> Option<T>
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true
if the Queue
is empty.
This operation should compute in O(1) time.
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns the length of the Queue
.
This operation should compute in O(1) time.
Sourcepub fn front(&self) -> Option<T>
pub fn front(&self) -> Option<T>
Provides a copy to the front element, or None
if the queue is
empty.
Sourcepub fn back(&self) -> Option<T>
pub fn back(&self) -> Option<T>
Provides a copy to the back element, or None
if the queue is
empty.
Sourcepub fn check_internal_consistency(&self) -> bool
pub fn check_internal_consistency(&self) -> bool
Runs several checks in order to verify that both forwards and backwards iteration yields the same node entries and that the number of items in the queue is correct. Used for unit testing.
This operation should compute in O(n) time.
Trait Implementations§
Source§impl<'a, SA, A, T> IntoIterator for &'a QueueMapper<SA, T, A>
impl<'a, SA, A, T> IntoIterator for &'a QueueMapper<SA, T, A>
Source§impl<SA, T> StorageClearable for QueueMapper<SA, T>
impl<SA, T> StorageClearable for QueueMapper<SA, T>
Source§impl<SA, T> StorageMapper<SA> for QueueMapper<SA, T>
impl<SA, T> StorageMapper<SA> for QueueMapper<SA, T>
Source§fn new(base_key: StorageKey<SA>) -> QueueMapper<SA, T>
fn new(base_key: StorageKey<SA>) -> QueueMapper<SA, T>
#[storage_mapper]
annotation generated code.Source§impl<SA, T> StorageMapperFromAddress<SA> for QueueMapper<SA, T, ManagedAddress<SA>>
impl<SA, T> StorageMapperFromAddress<SA> for QueueMapper<SA, T, ManagedAddress<SA>>
Source§fn new_from_address(
address: ManagedAddress<SA>,
base_key: StorageKey<SA>,
) -> QueueMapper<SA, T, ManagedAddress<SA>>
fn new_from_address( address: ManagedAddress<SA>, base_key: StorageKey<SA>, ) -> QueueMapper<SA, T, ManagedAddress<SA>>
#[storage_mapper_from_address]
annotation generated code.Source§impl<SA, T> TopEncodeMulti for QueueMapper<SA, T>
Behaves like a MultiResultVec when an endpoint result.
impl<SA, T> TopEncodeMulti for QueueMapper<SA, T>
Behaves like a MultiResultVec when an endpoint result.
Source§fn multi_encode_or_handle_err<O, H>(
&self,
output: &mut O,
h: H,
) -> Result<(), <H as EncodeErrorHandler>::HandledErr>where
O: TopEncodeMultiOutput,
H: EncodeErrorHandler,
fn multi_encode_or_handle_err<O, H>(
&self,
output: &mut O,
h: H,
) -> Result<(), <H as EncodeErrorHandler>::HandledErr>where
O: TopEncodeMultiOutput,
H: EncodeErrorHandler,
top_encode
that can handle errors as soon as they occur.
For instance in can exit immediately and make sure that if it returns, it is a success.
By not deferring error handling, this can lead to somewhat smaller bytecode.Source§fn multi_encode<O>(&self, output: &mut O) -> Result<(), EncodeError>where
O: TopEncodeMultiOutput,
fn multi_encode<O>(&self, output: &mut O) -> Result<(), EncodeError>where
O: TopEncodeMultiOutput,
Source§impl<SA, T> TypeAbi for QueueMapper<SA, T>
Behaves like a MultiResultVec when an endpoint result.
impl<SA, T> TypeAbi for QueueMapper<SA, T>
Behaves like a MultiResultVec when an endpoint result.
type Unmanaged = QueueMapper<SA, T>
fn type_name() -> String
fn type_name_rust() -> String
Source§fn provide_type_descriptions<TDC>(accumulator: &mut TDC)where
TDC: TypeDescriptionContainer,
fn provide_type_descriptions<TDC>(accumulator: &mut TDC)where
TDC: TypeDescriptionContainer,
fn type_names() -> TypeNames
impl<SA, T> TypeAbiFrom<QueueMapper<SA, T>> for MultiValueEncoded<SA, T>
impl<SA, T> TypeAbiFrom<QueueMapper<SA, T>> for QueueMapper<SA, T>
Auto Trait Implementations§
impl<SA, T, A> Freeze for QueueMapper<SA, T, A>
impl<SA, T, A> RefUnwindSafe for QueueMapper<SA, T, A>where
A: RefUnwindSafe,
SA: RefUnwindSafe,
T: RefUnwindSafe,
<SA as HandleTypeInfo>::ManagedBufferHandle: RefUnwindSafe,
impl<SA, T, A> Send for QueueMapper<SA, T, A>
impl<SA, T, A> Sync for QueueMapper<SA, T, A>
impl<SA, T, A> Unpin for QueueMapper<SA, T, A>
impl<SA, T, A> UnwindSafe for QueueMapper<SA, T, A>where
A: UnwindSafe,
SA: UnwindSafe,
T: UnwindSafe,
<SA as HandleTypeInfo>::ManagedBufferHandle: 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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> InterpretableFrom<T> for T
impl<T> InterpretableFrom<T> for T
fn interpret_from(from: T, _context: &InterpreterContext) -> T
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>
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>
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