Struct fral::rc::Fral
[−]
[src]
pub struct Fral<T> { /* fields omitted */ }
An immutable reference-based functional random-access list, built atop Rc
.
Methods
impl<T> Fral<T>
[src]
pub fn new() -> Fral<T>
[src]
Construct an empty list.
pub fn get(&self, index: usize) -> Option<Rc<T>>
[src]
Returns a reference to an element, or None
if it is out of bounds.
Time: O(log n)
Examples
use fral::rc::Fral; let f: Fral<_> = vec![7, 0, 17].into_iter().rev().collect(); assert_eq!(f.get(2), Some(Rc::new(17)));
pub fn cons<R>(&self, x: R) -> Fral<T> where
R: AsRc<T>,
[src]
R: AsRc<T>,
Insert an element at the front of the list.
Time: O(1)
pub fn uncons(&self) -> Option<(Rc<T>, Fral<T>)>
[src]
Get the head and tail of the list.
Time: O(1)
pub fn is_empty(&self) -> bool
[src]
Returns true iff the list contains no elements.
Time: O(1)
pub fn len(&self) -> usize
[src]
Get the number of items in the list.
Time: O(1)
ⓘImportant traits for Iter<T>pub fn iter(&self) -> Iter<T>
[src]
Trait Implementations
impl<T: Hash> Hash for Fral<T>
[src]
fn hash<__HT: Hasher>(&self, __arg_0: &mut __HT)
[src]
Feeds this value into the given [Hasher
]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl<T: Debug> Debug for Fral<T>
[src]
fn fmt(&self, __arg_0: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl<T: PartialEq> PartialEq for Fral<T>
[src]
fn eq(&self, __arg_0: &Fral<T>) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &Fral<T>) -> bool
[src]
This method tests for !=
.
impl<T: Eq> Eq for Fral<T>
[src]
impl<T> Clone for Fral<T>
[src]
fn clone(&self) -> Fral<T>
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<T> Default for Fral<T>
[src]
impl<T> IntoIterator for Fral<T>
[src]
type Item = Rc<T>
The type of the elements being iterated over.
type IntoIter = Iter<T>
Which kind of iterator are we turning this into?
ⓘImportant traits for Iter<T>fn into_iter(self) -> Iter<T>
[src]
Creates an iterator from a value. Read more
impl<T, R: AsRc<T>> FromIterator<R> for Fral<T>
[src]
This is done with repeated cons
, so you may intend to reverse your iterator first.
Examples
use fral::rc::Fral; let items = vec![1, 2, 3]; let f: Fral<_> = items.into_iter().collect(); // the first item in f is the last item of the iterator assert_eq!(f.get(0), Some(Rc::new(3)));
fn from_iter<I: IntoIterator<Item = R>>(iter: I) -> Fral<T>
[src]
Creates a value from an iterator. Read more