Skip to main content

RelativeLinkedList

Trait RelativeLinkedList 

Source
pub trait RelativeLinkedList<T: LinkType>: LinkedList<T> {
    // Required methods
    fn get_first(&self, head: T) -> T;
    fn get_last(&self, head: T) -> T;
    fn get_size(&self, head: T) -> T;
    fn set_first(&mut self, head: T, element: T);
    fn set_last(&mut self, head: T, element: T);
    fn set_size(&mut self, head: T, size: T);

    // Provided methods
    fn inc_size(&mut self, head: T) { ... }
    fn dec_size(&mut self, head: T) { ... }
}
Expand description

Linked list with head-relative access to first, last, and size.

Unlike AbsoluteLinkedList, this trait stores head/tail/size per head index, allowing multiple independent lists to share the same underlying node storage.

Required Methods§

Source

fn get_first(&self, head: T) -> T

Returns the first element of the list identified by head.

Source

fn get_last(&self, head: T) -> T

Returns the last element of the list identified by head.

Source

fn get_size(&self, head: T) -> T

Returns the size of the list identified by head.

Source

fn set_first(&mut self, head: T, element: T)

Sets the first element of the list identified by head.

Source

fn set_last(&mut self, head: T, element: T)

Sets the last element of the list identified by head.

Source

fn set_size(&mut self, head: T, size: T)

Sets the size of the list identified by head.

Provided Methods§

Source

fn inc_size(&mut self, head: T)

Increments the size of the list identified by head by one.

Source

fn dec_size(&mut self, head: T)

Decrements the size of the list identified by head by one.

Implementors§