Struct blist::BList [] [src]

pub struct BList<T> {
    // some fields omitted
}

A skeleton implementation of a BList, based on the Space-Efficient Linked List described in Open Data Structures.

A BList is a hybrid between an array and a doubly-linked-list. It consists of arrays in a doubly-linked-list. In this way we get many of the nice properties of a LinkedList, but with improved cache properties and less allocations.

A BList's B-factor is analogous to the same factor in a BTree. It guarantees that all nodes contain B-1 and B+1 elements (except the ends). Once a position has been identified to perform an insertion or deletion, it will take amortized O(B) time to perform, with a worst-case cost of O(B^2). Insertion and deletion on either end will always take O(1) time, though (assuming it takes O(1) time to allocate an array of size B).

Methods

impl<T> BList<T>
[src]

fn new() -> BList<T>

Creates a new BList with a reasonable choice for B.

fn with_b(b: usize) -> BList<T>

Creates a new BList with the specified B.

impl<T> BList<T>
[src]

fn push_back(&mut self, elem: T)

Inserts the element at the back of the list.

fn push_front(&mut self, elem: T)

Inserts the element at the front of the list.

fn pop_back(&mut self) -> Option<T>

Removes and returns an element off the back of the list. Returns None if empty.

fn pop_front(&mut self) -> Option<T>

Removes and returns an element off the front of the list. Returns None if empty.

fn front(&self) -> Option<&T>

Gets an immutable reference to the first element in the list.

fn back(&self) -> Option<&T>

Gets an immutable reference to the last element in the list.

fn front_mut(&mut self) -> Option<&mut T>

Gets a mutable reference to the first element in the list.

fn back_mut(&mut self) -> Option<&mut T>

Gets a mutable reference to the last element in the list.

fn len(&self) -> usize

Gets the number of elements in the list.

fn is_empty(&self) -> bool

Returns true if the list contains no elements, or false otherwise.

fn clear(&mut self)

Drops everything in the list.

fn iter(&self) -> Iter<T>

Gets a by-reference iterator over the elements in the list.

fn iter_mut(&mut self) -> IterMut<T>

Gets a by-mutable-reference iterator over the elements in the list.

fn into_iter(self) -> IntoIter<T>

Gets a by-value iterator over the elements in the list.

fn traversal(&self) -> Trav<T>

fn traversal_mut(&mut self) -> TravMut<T>

fn into_traversal(self) -> IntoTrav<T>

fn append_lazy(&mut self, other: &mut BList<T>)

Lazily moves the contents of other to the end of self, in the sense that it makes no effort to preserve the node-size lower-bound invariant. This can have negative effects on the effeciency of the resulting list, but is otherwise much faster than a proper invariant-preserving append.

Panics

Panics if the lists have a different value of B.

Trait Implementations

impl<T: Clone> Clone for BList<T>
[src]

fn clone(&self) -> BList<T>

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)
1.0.0

Performs copy-assignment from source. Read more

impl<'a, T> IntoIterator for &'a BList<T>
[src]

type Item = &'a T

The type of the elements being iterated over.

type IntoIter = Iter<'a, T>

Which kind of iterator are we turning this into?

fn into_iter(self) -> Iter<'a, T>

Creates an iterator from a value. Read more

impl<'a, T> IntoIterator for &'a mut BList<T>
[src]

type Item = &'a mut T

The type of the elements being iterated over.

type IntoIter = IterMut<'a, T>

Which kind of iterator are we turning this into?

fn into_iter(self) -> IterMut<'a, T>

Creates an iterator from a value. Read more

impl<T> IntoIterator for BList<T>
[src]

type Item = T

The type of the elements being iterated over.

type IntoIter = IntoIter<T>

Which kind of iterator are we turning this into?

fn into_iter(self) -> IntoIter<T>

Creates an iterator from a value. Read more

impl<A> FromIterator<A> for BList<A>
[src]

fn from_iter<T: IntoIterator<Item=A>>(iter: T) -> BList<A>

Creates a value from an iterator. Read more

impl<A> Extend<A> for BList<A>
[src]

fn extend<T: IntoIterator<Item=A>>(&mut self, iter: T)

Extends a collection with the contents of an iterator. Read more

impl<A: PartialEq> PartialEq for BList<A>
[src]

fn eq(&self, other: &Self) -> bool

This method tests for self and other values to be equal, and is used by ==. Read more

fn ne(&self, other: &Rhs) -> bool
1.0.0

This method tests for !=.

impl<A: Eq> Eq for BList<A>
[src]

impl<A: PartialOrd> PartialOrd for BList<A>
[src]

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more

fn lt(&self, other: &Rhs) -> bool
1.0.0

This method tests less than (for self and other) and is used by the < operator. Read more

fn le(&self, other: &Rhs) -> bool
1.0.0

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

fn gt(&self, other: &Rhs) -> bool
1.0.0

This method tests greater than (for self and other) and is used by the > operator. Read more

fn ge(&self, other: &Rhs) -> bool
1.0.0

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

impl<A: Ord> Ord for BList<A>
[src]

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more

impl<A: Debug> Debug for BList<A>
[src]

fn fmt(&self, f: &mut Formatter) -> Result

Formats the value using the given formatter.

impl<A: Hash> Hash for BList<A>
[src]

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the state given, updating the hasher as necessary.

fn hash_slice<H>(data: &[Self], state: &mut H) where H: Hasher
1.3.0

Feeds a slice of this type into the state provided.