[−][src]Trait arae::CursedExt
Extended functionality for implementations of Cursed
.
Provided methods
fn get(&self, cursor: Cursor<T>) -> &T
Returns a reference to the element at the given Cursor
.
Example
use arae::{CurVec, CursedExt, Bounded}; let mut vec: CurVec<_> = vec![0].into(); assert_eq!(*vec.get(vec.head()), 0);
Panics
Panics if self
does not own the Cursor
.
fn get_mut(&mut self, cursor: Cursor<T>) -> &mut T
Returns a mutable reference to the element at the given Cursor
.
Example
use arae::{CurVec, CursedExt, Bounded}; let mut vec: CurVec<_> = vec![0].into(); *vec.get_mut(vec.head()) = 1; assert_eq!(*vec.get(vec.head()), 1);
Panics
Panics if self
does not own the Cursor
.
fn is_head(&self, cursor: Cursor<T>) -> bool where
Self: Bounded<T>,
Self: Bounded<T>,
Returns true
if the Cursor
points at the first element, false
if not.
fn is_tail(&self, cursor: Cursor<T>) -> bool where
Self: Bounded<T>,
Self: Bounded<T>,
Returns true
if the Cursor
points at the last element, false
if not.
fn offset(&self, cursor: Cursor<T>) -> usize where
Self: Bounded<T>,
Self: Bounded<T>,
fn wrapping_next(&self, cursor: Cursor<T>) -> Cursor<T> where
Self: Bounded<T>,
Self: Bounded<T>,
Given a Cursor
, return its next element step.
If the Cursor
provided points to the end of the structure,
the Cursor
returned will wrap and point to the start.
Example
use arae::{CurVec, CursedExt, Bounded}; let vec: CurVec<_> = vec![1, 2, 3].into(); let cursor = vec.wrapping_next(vec.tail()); assert_eq!(*vec.get(cursor), 1);
Panics
Panics if self
does not own the Cursor
.
fn wrapping_prev(&self, cursor: Cursor<T>) -> Cursor<T> where
Self: Bounded<T>,
Self: Bounded<T>,
Given a Cursor
, return its previous element step.
If the Cursor
provided points to the head
of the structure,
the Cursor
returned will wrap and point to the tail
.
Example
use arae::{CurVec, CursedExt, Bounded}; let vec: CurVec<_> = vec![1, 2, 3].into(); let cursor = vec.wrapping_prev(vec.head()); assert_eq!(*vec.get(cursor), 3);
Panics
Panics if self
does not own the Cursor
.
ⓘImportant traits for Iter<'a, C, T>fn iter(&self) -> Iter<Self, T> where
Self: Bounded<T>,
Self: Bounded<T>,
Returns a Iterator<Item = (&T, Cursor<T>)>
that starts at the head
.
Example
use arae::{CurVec, CursedExt}; let vec: CurVec<_> = vec![1, 2].into(); for (elem, cursor) in vec.iter() { println!("elem {} at {:?}:", elem, cursor); }
ⓘImportant traits for Iter<'a, C, T>fn iter_at(&self, cursor: Cursor<T>) -> Iter<Self, T> where
Self: Sequence<T>,
Self: Sequence<T>,
Returns a Iterator<Item = (&T, Cursor<T>)>
that starts at the given Cursor
.
Example
use arae::{CurVec, CursedExt, Bounded}; let vec: CurVec<_> = vec![1, 2].into(); for (elem, cursor) in vec.iter_at(vec.head()) { println!("elem {} at {:?}:", elem, cursor); }
ⓘImportant traits for WrappingIter<'a, C, T>fn wrapping_iter(&self) -> WrappingIter<Self, T> where
Self: Bounded<T>,
Self: Bounded<T>,
Returns a wrapping Iterator<Item = (&T, Cursor<T>)>
that starts at
the head
.
This iterator is never ending and will wrap from the tail
to the
head
and vice-versa when iterating in the opposite direction.
Example
use arae::{CurVec, CursedExt}; let vec: CurVec<_> = vec![1, 2].into(); for (elem, cursor) in vec.wrapping_iter() { println!("elem: {}", elem); if vec.is_tail(cursor) { break; } }
ⓘImportant traits for WrappingIter<'a, C, T>fn wrapping_iter_at(&self, cursor: Cursor<T>) -> WrappingIter<Self, T> where
Self: Sequence<T>,
Self: Sequence<T>,
Returns a wrapping Iterator<Item = (&T, Cursor<T>)>
that starts at
the given Cursor
.
This iterator is never ending and will wrap from the tail
to the
head
and vice-versa when iterating in the opposite direction.
Example
use arae::{CurVec, CursedExt, Bounded}; let vec: CurVec<_> = vec![1, 2].into(); for (elem, cursor) in vec.wrapping_iter_at(vec.head()) { println!("elem: {}", elem); if vec.is_tail(cursor) { break; } }