Struct unrolled_linked_list::UnrolledLinkedList[][src]

pub struct UnrolledLinkedList<T> { /* fields omitted */ }
Expand description

The unrolled linked list. The list that acts like a linked list but has the node structure inside.

Implementations

Provides a forward iterator.

Examples


use unrolled_linked_list::UnrolledLinkedList;

let mut list: UnrolledLinkedList<u32> = UnrolledLinkedList::new();

list.push(0);
list.push(1);
list.push(2);

let mut iter = list.iter();
assert_eq!(iter.next(), Some(&0));
assert_eq!(iter.next(), Some(&1));
assert_eq!(iter.next(), Some(&2));
assert_eq!(iter.next(), None);

Provides a forward mut iterator.

Examples


use unrolled_linked_list::UnrolledLinkedList;

let mut list: UnrolledLinkedList<u32> = UnrolledLinkedList::new();

list.push(0);
list.push(1);
list.push(2);

for element in list.iter_mut() {
    *element += 10;
}

let mut iter = list.iter();
assert_eq!(iter.next(), Some(&10));
assert_eq!(iter.next(), Some(&11));
assert_eq!(iter.next(), Some(&12));
assert_eq!(iter.next(), None);

The default initiation, setting the size of node to 8.

Examples

use unrolled_linked_list::UnrolledLinkedList;

let list: UnrolledLinkedList<u32> = UnrolledLinkedList::new();

Capacity defines the size of the node.

Examples

use unrolled_linked_list::UnrolledLinkedList;

let list: UnrolledLinkedList<u32> = UnrolledLinkedList::with_capacity(4);

Adds an element last in the list.

Examples


use unrolled_linked_list::UnrolledLinkedList;
let mut dl = UnrolledLinkedList::new();

dl.push(2);
assert_eq!(dl.pop().unwrap(), 2);

dl.push(1);
assert_eq!(dl.pop().unwrap(), 1);

Adds an element last in the list.

Panics

Panics if index > len.

Examples


use unrolled_linked_list::UnrolledLinkedList;
let mut dl = UnrolledLinkedList::new();

dl.insert(0,0);
assert_eq!(dl.pop().unwrap(), 0);

removes the last element from the list and returns it.

Examples


use unrolled_linked_list::UnrolledLinkedList;
let mut dl = UnrolledLinkedList::new();

dl.insert(0,0);
assert_eq!(dl.pop().unwrap(), 0);

removes the custom element from the list accordign to the index and returns it.

Panics

Panics if index >= len.

Examples


use unrolled_linked_list::UnrolledLinkedList;
let mut dl = UnrolledLinkedList::new();

dl.insert(0,0);
assert_eq!(dl.remove(0), 0);

retrieves the custom element from the list according to the index and returns it.

Examples


use unrolled_linked_list::UnrolledLinkedList;
let mut dl = UnrolledLinkedList::new();

dl.insert(0,0);
dl.insert(1,1);
assert_eq!(dl.get(1), Some(&1));
assert_eq!(dl.get(0), Some(&0));

retrieves the custom element from the list according to the index and returns the mutable reference.

Examples


use unrolled_linked_list::UnrolledLinkedList;
let mut dl = UnrolledLinkedList::new();

dl.insert(0,0);
dl.insert(1,1);
assert_eq!(dl.get_mut(1), Some(&mut 1));
assert_eq!(dl.get_mut(0), Some(&mut 0));

Returns true if the UnrolledLinkedList is empty.

This operation should compute in O(1) time.

Returns the length of the UnrolledLinkedList.

This operation should compute in O(1) time.

Removes all elements from the LinkedList.

This operation should compute in O(n) time.

Returns true if the LinkedList contains an element equal to the given value.

Trait Implementations

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Formats the value using the given formatter. Read more

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

Creates an iterator from a value. Read more

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

Creates an iterator from a value. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.