[−][src]Trait glsp::DequeOps
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>
Required methods
fn push<V>(&self, val: V) -> Result<(), GError> where
V: IntoElement<Self::Element>,
V: IntoElement<Self::Element>,
Pushes an element to the end of the deque.
Equivalent to (push! deq val)
.
fn pop<R>(&self) -> Result<R, GError> where
R: FromElement<Self::Element>,
R: FromElement<Self::Element>,
Pops an element from the end of the deque.
Equivalent to (pop! deq)
.
fn push_start<V>(&self, val: V) -> Result<(), GError> where
V: IntoElement<Self::Element>,
V: IntoElement<Self::Element>,
Pushes an element to the beginning of the deque.
Equivalent to (push-start! deq val)
.
fn pop_start<R>(&self) -> Result<R, GError> where
R: FromElement<Self::Element>,
R: FromElement<Self::Element>,
Pops an element from the beginning of the deque.
Equivalent to (pop-start! deq)
.
fn grow<V>(
&self,
start_to_add: usize,
end_to_add: usize,
fill: V
) -> Result<(), GError> where
V: IntoElement<Self::Element>,
&self,
start_to_add: usize,
end_to_add: usize,
fill: V
) -> Result<(), GError> where
V: IntoElement<Self::Element>,
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
) -> Result<(), GError>
&self,
start_to_remove: usize,
end_to_remove: usize
) -> Result<(), GError>
Decreases the deque's size.
Equivalent to (shrink! deq start-n end-n
.
fn append(&self, other: &Self) -> Result<(), GError>
Pushes the contents of another deque onto the end of this one.
fn prepend(&self, other: &Self) -> Result<(), GError>
Pushes the contents of another deque onto the beginning of this one.
fn resize<V>(&self, new_len: usize, val: V) -> Result<(), GError> where
V: IntoElement<Self::Element>,
V: IntoElement<Self::Element>,
Resizes the deque.
Equivalent to VecDeque::resize
.
fn rotate_left(&self, mid: usize) -> Result<(), GError>
Rotates the deque to the left
Equivalent to VecDeque::rotate_left
.
fn rotate_right(&self, k: usize) -> Result<(), GError>
Rotates the deque to the right.
Equivalent to VecDeque::rotate_right
.
fn swap<I1, I2>(&self, i: I1, j: I2) -> Result<(), GError> where
I1: DequeIndex,
I2: DequeIndex,
I1: DequeIndex,
I2: DequeIndex,
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) -> Result<(), GError>
Reserves enough space for exactly additional
elements to be added to the deque.
Equivalent to VecDeque::reserve_exact
.
fn reserve(&self, additional: usize) -> Result<(), GError>
Reserves enough space for at least additional
elements to be added to the deque.
Equivalent to VecDeque::reserve
.
fn shrink_to_fit(&self) -> Result<(), GError>
Shrinks the capacity of the deque as much as possible.
Equivalent to VecDeque::shrink_to_fit
.
fn truncate(&self, len: usize) -> Result<(), GError>
Reduces the deque's length.
Equivalent to VecDeque::truncate
.
fn clear(&self) -> Result<(), GError>
Removes all of the deque's elements.
Equivalent to VecDeque::clear
.
fn contains<V>(&self, x: V) -> Result<bool, GError> where
V: IntoElement<Self::Element>,
V: IntoElement<Self::Element>,
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) -> Result<(), GError> where
I: IntoIterator<Item = V>,
V: IntoElement<Self::Element>,
I: IntoIterator<Item = V>,
V: IntoElement<Self::Element>,
Pushes the contents of an iterator onto the end of the deque.
Provided methods
fn is_empty(&self) -> bool
Returns true
if the deque's length is 0.
Equivalent to (empty? deq)
.
fn iter(&'a self) -> IterDeque<'a, Self> where
Self: DequeAccess<usize>,
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<R>(&'a self) -> IterDequeTo<'a, Self, R> where
R: FromElement<Self::Element>,
Self: DequeAccess<usize>,
R: FromElement<Self::Element>,
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.
Implementors
impl DequeOps for Deque
[src]
type Element = Slot
type Item = Val
fn freeze(&self)
[src]
fn deep_freeze(&self)
[src]
fn is_frozen(&self) -> bool
[src]
fn is_deep_frozen(&self) -> bool
[src]
fn can_mutate(&self) -> bool
[src]
fn swap<I1, I2>(&self, i: I1, j: I2) -> Result<(), GError> where
I1: DequeIndex,
I2: DequeIndex,
[src]
I1: DequeIndex,
I2: DequeIndex,
fn len(&self) -> usize
[src]
fn contains<V>(&self, v: V) -> Result<bool, GError> where
V: IntoElement<Slot>,
[src]
V: IntoElement<Slot>,
fn push<V>(&self, v: V) -> Result<(), GError> where
V: IntoElement<Slot>,
[src]
V: IntoElement<Slot>,
fn pop<R>(&self) -> Result<R, GError> where
R: FromElement<Slot>,
[src]
R: FromElement<Slot>,
fn push_start<V>(&self, v: V) -> Result<(), GError> where
V: IntoElement<Slot>,
[src]
V: IntoElement<Slot>,
fn pop_start<R>(&self) -> Result<R, GError> where
R: FromElement<Slot>,
[src]
R: FromElement<Slot>,
fn grow<V>(&self, start: usize, end: usize, fill: V) -> Result<(), GError> where
V: IntoElement<Slot>,
[src]
V: IntoElement<Slot>,
fn shrink(&self, start: usize, end: usize) -> Result<(), GError>
[src]
fn append(&self, _other: &Deque) -> Result<(), GError>
[src]
fn prepend(&self, _other: &Deque) -> Result<(), GError>
[src]
fn resize<V>(&self, new_len: usize, fill: V) -> Result<(), GError> where
V: IntoElement<Slot>,
[src]
V: IntoElement<Slot>,
fn rotate_left(&self, mid: usize) -> Result<(), GError>
[src]
fn rotate_right(&self, k: usize) -> Result<(), GError>
[src]
fn capacity(&self) -> usize
[src]
fn reserve_exact(&self, additional: usize) -> Result<(), GError>
[src]
fn reserve(&self, additional: usize) -> Result<(), GError>
[src]
fn shrink_to_fit(&self) -> Result<(), GError>
[src]
fn truncate(&self, len: usize) -> Result<(), GError>
[src]
fn clear(&self) -> Result<(), GError>
[src]
fn extend<I, C>(&self, source: I) -> Result<(), GError> where
C: IntoElement<Slot>,
I: IntoIterator<Item = C>,
[src]
C: IntoElement<Slot>,
I: IntoIterator<Item = C>,
impl DequeOps for Arr
[src]
type Element = Slot
type Item = Val
fn freeze(&self)
[src]
fn deep_freeze(&self)
[src]
fn is_frozen(&self) -> bool
[src]
fn is_deep_frozen(&self) -> bool
[src]
fn can_mutate(&self) -> bool
[src]
fn push<V>(&self, val: V) -> Result<(), GError> where
V: IntoElement<Slot>,
[src]
V: IntoElement<Slot>,
fn pop<R>(&self) -> Result<R, GError> where
R: FromElement<Slot>,
[src]
R: FromElement<Slot>,
fn push_start<V>(&self, val: V) -> Result<(), GError> where
V: IntoElement<Slot>,
[src]
V: IntoElement<Slot>,
fn pop_start<R>(&self) -> Result<R, GError> where
R: FromElement<Slot>,
[src]
R: FromElement<Slot>,
fn grow<V>(
&self,
start_to_add: usize,
end_to_add: usize,
fill: V
) -> Result<(), GError> where
V: IntoElement<Slot>,
[src]
&self,
start_to_add: usize,
end_to_add: usize,
fill: V
) -> Result<(), GError> where
V: IntoElement<Slot>,
fn shrink(
&self,
start_to_remove: usize,
end_to_remove: usize
) -> Result<(), GError>
[src]
&self,
start_to_remove: usize,
end_to_remove: usize
) -> Result<(), GError>
fn append(&self, other: &Arr) -> Result<(), GError>
[src]
fn prepend(&self, other: &Arr) -> Result<(), GError>
[src]
fn resize<V>(&self, new_len: usize, fill: V) -> Result<(), GError> where
V: IntoElement<Slot>,
[src]
V: IntoElement<Slot>,
fn rotate_left(&self, mid: usize) -> Result<(), GError>
[src]
fn rotate_right(&self, k: usize) -> Result<(), GError>
[src]
fn swap<I1, I2>(&self, index1: I1, index2: I2) -> Result<(), GError> where
I1: DequeIndex,
I2: DequeIndex,
[src]
I1: DequeIndex,
I2: DequeIndex,
fn capacity(&self) -> usize
[src]
fn len(&self) -> usize
[src]
fn reserve_exact(&self, additional: usize) -> Result<(), GError>
[src]
fn reserve(&self, additional: usize) -> Result<(), GError>
[src]
fn shrink_to_fit(&self) -> Result<(), GError>
[src]
fn truncate(&self, len: usize) -> Result<(), GError>
[src]
fn clear(&self) -> Result<(), GError>
[src]
fn contains<V>(&self, x: V) -> Result<bool, GError> where
V: IntoElement<Slot>,
[src]
V: IntoElement<Slot>,
fn extend<I, V>(&self, source: I) -> Result<(), GError> where
I: IntoIterator<Item = V>,
V: IntoElement<Slot>,
[src]
I: IntoIterator<Item = V>,
V: IntoElement<Slot>,
impl DequeOps for Str
[src]
type Element = char
type Item = char
fn freeze(&self)
[src]
fn deep_freeze(&self)
[src]
fn is_frozen(&self) -> bool
[src]
fn is_deep_frozen(&self) -> bool
[src]
fn can_mutate(&self) -> bool
[src]
fn push<C>(&self, ch: C) -> Result<(), GError> where
C: IntoElement<char>,
[src]
C: IntoElement<char>,
fn pop<R>(&self) -> Result<R, GError> where
R: FromElement<char>,
[src]
R: FromElement<char>,
fn push_start<C>(&self, ch: C) -> Result<(), GError> where
C: IntoElement<char>,
[src]
C: IntoElement<char>,
fn pop_start<R>(&self) -> Result<R, GError> where
R: FromElement<char>,
[src]
R: FromElement<char>,
fn grow<C>(
&self,
start_to_add: usize,
end_to_add: usize,
fill: C
) -> Result<(), GError> where
C: IntoElement<char>,
[src]
&self,
start_to_add: usize,
end_to_add: usize,
fill: C
) -> Result<(), GError> where
C: IntoElement<char>,
fn shrink(
&self,
start_to_remove: usize,
end_to_remove: usize
) -> Result<(), GError>
[src]
&self,
start_to_remove: usize,
end_to_remove: usize
) -> Result<(), GError>
fn append(&self, other: &Str) -> Result<(), GError>
[src]
fn prepend(&self, other: &Str) -> Result<(), GError>
[src]
fn resize<C>(&self, new_len: usize, ch: C) -> Result<(), GError> where
C: IntoElement<char>,
[src]
C: IntoElement<char>,
fn rotate_left(&self, mid: usize) -> Result<(), GError>
[src]
fn rotate_right(&self, k: usize) -> Result<(), GError>
[src]
fn swap<I1, I2>(&self, i_index: I1, j_index: I2) -> Result<(), GError> where
I1: DequeIndex,
I2: DequeIndex,
[src]
I1: DequeIndex,
I2: DequeIndex,
fn capacity(&self) -> usize
[src]
fn len(&self) -> usize
[src]
fn reserve_exact(&self, additional: usize) -> Result<(), GError>
[src]
fn reserve(&self, additional: usize) -> Result<(), GError>
[src]
fn shrink_to_fit(&self) -> Result<(), GError>
[src]
fn truncate(&self, len: usize) -> Result<(), GError>
[src]
fn clear(&self) -> Result<(), GError>
[src]
fn contains<C>(&self, ch: C) -> Result<bool, GError> where
C: IntoElement<char>,
[src]
C: IntoElement<char>,
fn extend<I, C>(&self, source: I) -> Result<(), GError> where
C: IntoElement<char>,
I: IntoIterator<Item = C>,
[src]
C: IntoElement<char>,
I: IntoIterator<Item = C>,