Skip to main content

AbsoluteCircularLinkedList

Trait AbsoluteCircularLinkedList 

Source
pub trait AbsoluteCircularLinkedList<T: LinkType>: AbsoluteLinkedList<T> {
    // Provided methods
    fn attach_before(&mut self, base_element: T, new_element: T) { ... }
    fn attach_after(&mut self, base_element: T, new_element: T) { ... }
    fn attach_as_first(&mut self, element: T) { ... }
    fn attach_as_last(&mut self, element: T) { ... }
    fn detach(&mut self, element: T) { ... }
}
Expand description

Circular doubly-linked list with absolute (direct) head/tail access.

Provides attach_before, attach_after, attach_as_first, attach_as_last, and detach operations that maintain circular links and update the head/tail/size automatically.

All methods have default implementations — an empty impl block is sufficient once AbsoluteLinkedList is implemented.

Provided Methods§

Source

fn attach_before(&mut self, base_element: T, new_element: T)

Inserts new_element immediately before base_element.

If base_element is the current first element, the first pointer is updated to new_element.

Source

fn attach_after(&mut self, base_element: T, new_element: T)

Inserts new_element immediately after base_element.

If base_element is the current last element, the last pointer is updated to new_element.

Source

fn attach_as_first(&mut self, element: T)

Inserts element as the first element of the list.

If the list is empty, element becomes both first and last, with its previous and next pointers pointing to itself.

Source

fn attach_as_last(&mut self, element: T)

Inserts element as the last element of the list.

If the list is empty, delegates to attach_as_first.

Source

fn detach(&mut self, element: T)

Removes element from the list.

Updates head/tail pointers as needed and clears the element’s previous and next pointers to T::funty(0).

Implementors§