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);
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);
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.
Trait Implementations
Auto Trait Implementations
impl<T> RefUnwindSafe for UnrolledLinkedList<T> where
T: RefUnwindSafe,
impl<T> !Send for UnrolledLinkedList<T>
impl<T> !Sync for UnrolledLinkedList<T>
impl<T> Unpin for UnrolledLinkedList<T>
impl<T> UnwindSafe for UnrolledLinkedList<T> where
T: RefUnwindSafe,