[][src]Trait glsp_engine::DequeOps

pub trait DequeOps: Sized + Sealed {
    type Element;
    type Item: FromElement<Self::Element>;
    fn push<V: IntoElement<Self::Element>>(&self, val: V) -> GResult<()>;
fn pop<R: FromElement<Self::Element>>(&self) -> GResult<R>;
fn push_start<V: IntoElement<Self::Element>>(&self, val: V) -> GResult<()>;
fn pop_start<R: FromElement<Self::Element>>(&self) -> GResult<R>;
fn grow<V: IntoElement<Self::Element>>(
        &self,
        start_to_add: usize,
        end_to_add: usize,
        fill: V
    ) -> GResult<()>;
fn shrink(
        &self,
        start_to_remove: usize,
        end_to_remove: usize
    ) -> GResult<()>;
fn append(&self, other: &Self) -> GResult<()>;
fn prepend(&self, other: &Self) -> GResult<()>;
fn resize<V: IntoElement<Self::Element>>(
        &self,
        new_len: usize,
        val: V
    ) -> GResult<()>;
fn rotate_left(&self, mid: usize) -> GResult<()>;
fn rotate_right(&self, k: usize) -> GResult<()>;
fn swap<I1: DequeIndex, I2: DequeIndex>(&self, i: I1, j: I2) -> GResult<()>;
fn capacity(&self) -> usize;
fn len(&self) -> usize;
fn reserve_exact(&self, additional: usize) -> GResult<()>;
fn reserve(&self, additional: usize) -> GResult<()>;
fn shrink_to_fit(&self) -> GResult<()>;
fn truncate(&self, len: usize) -> GResult<()>;
fn clear(&self) -> GResult<()>;
fn contains<V: IntoElement<Self::Element>>(&self, x: V) -> GResult<bool>;
fn freeze(&self);
fn deep_freeze(&self);
fn is_frozen(&self) -> bool;
fn is_deep_frozen(&self) -> bool;
fn can_mutate(&self) -> bool;
fn extend<I, V>(&self, source: I) -> GResult<()>
    where
        I: IntoIterator<Item = V>,
        V: IntoElement<Self::Element>
; fn is_empty(&self) -> bool { ... }
fn iter<'a>(&'a self) -> IterDeque<'a, Self>
    where
        Self: DequeAccess<usize>
, { ... }
fn iter_to<'a, R: FromElement<Self::Element>>(
        &'a self
    ) -> IterDequeTo<'a, Self, R>
    where
        Self: DequeAccess<usize>
, { ... } }

The deque abstract type.

When manipulating an Arr, Str or Deque, you'll mostly use this trait's methods.

This trait defines all of a deque's operations other than indexing. For indexing a deque, use the traits DequeAccess and DequeAccessRange.

This trait is sealed. It's not possible to implement this trait for your own types.

Associated Types

type Element

type Item: FromElement<Self::Element>

Loading content...

Required methods

fn push<V: IntoElement<Self::Element>>(&self, val: V) -> GResult<()>

Pushes an element to the end of the deque.

Equivalent to (push! deq val).

fn pop<R: FromElement<Self::Element>>(&self) -> GResult<R>

Pops an element from the end of the deque.

Equivalent to (pop! deq).

fn push_start<V: IntoElement<Self::Element>>(&self, val: V) -> GResult<()>

Pushes an element to the beginning of the deque.

Equivalent to (push-start! deq val).

fn pop_start<R: FromElement<Self::Element>>(&self) -> GResult<R>

Pops an element from the beginning of the deque.

Equivalent to (pop-start! deq).

fn grow<V: IntoElement<Self::Element>>(
    &self,
    start_to_add: usize,
    end_to_add: usize,
    fill: V
) -> GResult<()>

Increases the deque's size.

Equivalent to (grow! deq start-n end-n fill).

fn shrink(&self, start_to_remove: usize, end_to_remove: usize) -> GResult<()>

Decreases the deque's size.

Equivalent to (shrink! deq start-n end-n.

fn append(&self, other: &Self) -> GResult<()>

Pushes the contents of another deque onto the end of this one.

fn prepend(&self, other: &Self) -> GResult<()>

Pushes the contents of another deque onto the beginning of this one.

fn resize<V: IntoElement<Self::Element>>(
    &self,
    new_len: usize,
    val: V
) -> GResult<()>

Resizes the deque.

Equivalent to VecDeque::resize.

fn rotate_left(&self, mid: usize) -> GResult<()>

Rotates the deque to the left

Equivalent to VecDeque::rotate_left.

fn rotate_right(&self, k: usize) -> GResult<()>

Rotates the deque to the right.

Equivalent to VecDeque::rotate_right.

fn swap<I1: DequeIndex, I2: DequeIndex>(&self, i: I1, j: I2) -> GResult<()>

Swaps two of the deque's elements.

Equivalent to (swap! [deq i] [deq j]).

fn capacity(&self) -> usize

Returns the deque's storage capacity.

Equivalent to VecDeque::capacity.

fn len(&self) -> usize

Returns the deque's length.

Equivalent to (len deq).

fn reserve_exact(&self, additional: usize) -> GResult<()>

Reserves enough space for exactly additional elements to be added to the deque.

Equivalent to VecDeque::reserve_exact.

fn reserve(&self, additional: usize) -> GResult<()>

Reserves enough space for at least additional elements to be added to the deque.

Equivalent to VecDeque::reserve.

fn shrink_to_fit(&self) -> GResult<()>

Shrinks the capacity of the deque as much as possible.

Equivalent to VecDeque::shrink_to_fit.

fn truncate(&self, len: usize) -> GResult<()>

Reduces the deque's length.

Equivalent to VecDeque::truncate.

fn clear(&self) -> GResult<()>

Removes all of the deque's elements.

Equivalent to VecDeque::clear.

fn contains<V: IntoElement<Self::Element>>(&self, x: V) -> GResult<bool>

Tests whether the deque contains an element which compares eq? to the argument.

Equivalent to VecDeque::contains.

fn freeze(&self)

Makes the deque immutable.

Equivalent to (freeze! deq).

fn deep_freeze(&self)

Makes the deque and all of its contents immutable.

Equivalent to (deep-freeze! deq).

fn is_frozen(&self) -> bool

Returns true if the deque has been frozen.

fn is_deep_frozen(&self) -> bool

Returns true if the deque and all of its contents have been frozen.

fn can_mutate(&self) -> bool

Returns true if it's possible to mutate the deque without triggering an error.

This method will currently return false if the deque has been frozen, or if it's currently being iterated from Rust.

fn extend<I, V>(&self, source: I) -> GResult<()> where
    I: IntoIterator<Item = V>,
    V: IntoElement<Self::Element>, 

Pushes the contents of an iterator onto the end of the deque.

Loading content...

Provided methods

fn is_empty(&self) -> bool

Returns true if the deque's length is 0.

Equivalent to (empty? deq).

fn iter<'a>(&'a self) -> IterDeque<'a, Self> where
    Self: DequeAccess<usize>, 

Creates an infallible iterator over this deque.

The iterator's item type will be Val for Arr and Deque, or char for Str.

fn iter_to<'a, R: FromElement<Self::Element>>(
    &'a self
) -> IterDequeTo<'a, Self, R> where
    Self: DequeAccess<usize>, 

Creates a converting iterator over this deque.

The iterator can produce any type which implements FromElement, but each item will be wrapped in a GResult<T>, so it will need to be unwrapped using ? before it can be used.

Loading content...

Implementors

impl DequeOps for Deque[src]

type Element = Slot

type Item = Val

impl DequeOps for Arr[src]

type Element = Slot

type Item = Val

impl DequeOps for Str[src]

type Element = char

type Item = char

Loading content...