[][src]Struct orga::collections::Deque

pub struct Deque<S: Read, T: Encode + Decode> { /* fields omitted */ }

A double-ended queue data structure.

Implementations

impl<S: Read, T: Encode + Decode> Deque<S, T>[src]

pub fn len(&self) -> u64[src]

Gets the length of the deque.

This method does not read from the state since the head and tail indices are kept in memory, so it is a cheap operation.

pub fn get(&self, index: u64) -> Result<T>[src]

Gets the element with the given index.

If the index is out of bounds, this method will panic. If getting from the store or decoding the store value returns an error, this method will return the error.

pub fn fixed_index(&self, index: u64) -> u64[src]

Calculates the current fixed index of the given index.

An element's fixed index remains constant even as elements are pushed or popped from the front of the deque. This is useful when storing data which references other elements of the deque, using the index as a pseudo-pointer.

For example, if we have a deque with 2 elements, "foo" and "bar", index 0 will be "foo" and index 1 will be "bar". But if we pop "foo", now index 0 will be "bar", but its fixed index will still be 1.

pub fn get_fixed(&self, index: u64) -> Result<T>[src]

Gets an element by its fixed index.

See [#method.fixed_index] for more info about fixed indices.

pub fn iter<'a>(&'a self) -> Iter<'a, S, T>[src]

Creates an iterator over the deque's elements.

Iteration happens in order by index.

pub fn is_empty(&self) -> bool[src]

Returns true if the deque has length 0, false otherwise.

This method does not read from the state since the head and tail indices are kept in memory, so it is a cheap operation.

pub fn back(&self) -> Result<Option<T>>[src]

Gets the last element of the deque, or None if the deque is empty.

impl<S: Store, T: Encode + Decode> Deque<S, T>[src]

pub fn push_back(&mut self, value: T) -> Result<()>[src]

Appends an element to the back of the deque.

pub fn pop_front(&mut self) -> Result<Option<T>>[src]

Pops an element off the front of the deque and deletes it, then returns the popped value.

pub fn set(&mut self, index: u64, value: T) -> Result<()>[src]

Replaces the element at the given index.

pub fn clear(&mut self) -> Result<()>[src]

Removes all elements.

This operation will be expensive for large deques, since each element is individually deleted.

pub fn drain_into<S2: Store>(&mut self, other: &mut Deque<S2, T>) -> Result<()>[src]

Removes all elements and appends them to the given deque in order.

This operation will be expensive for large deques, since each element is individually deleted then pushed.

Trait Implementations

impl<S: Read, T: Encode + Decode> State<S> for Deque<S, T>[src]

fn wrap_store(store: S) -> Result<Self>[src]

Wraps the store to allow reading from and writing to the deque.

This wrap_store implementation will also read the Meta value (containing the head and tail indices) and store its contents in memory.

Auto Trait Implementations

impl<S, T> RefUnwindSafe for Deque<S, T> where
    S: RefUnwindSafe,
    T: RefUnwindSafe

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

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

impl<S, T> Terminated for Deque<S, T> where
    S: Terminated,
    T: Terminated

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

impl<S, T> UnwindSafe for Deque<S, T> where
    S: UnwindSafe,
    T: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,