pub struct SinglyLinkedList<A: Adapter>where
    A::LinkOps: SinglyLinkedListOps,{ /* private fields */ }
Expand description

An intrusive singly-linked list.

When this collection is dropped, all elements linked into it will be converted back to owned pointers and dropped.

Implementations§

source§

impl<A: Adapter> SinglyLinkedList<A>where A::LinkOps: SinglyLinkedListOps,

source

pub fn new(adapter: A) -> SinglyLinkedList<A>

Creates an empty SinglyLinkedList.

source

pub fn is_empty(&self) -> bool

Returns true if the SinglyLinkedList is empty.

source

pub fn cursor(&self) -> Cursor<'_, A>

Returns a null Cursor for this list.

source

pub fn cursor_mut(&mut self) -> CursorMut<'_, A>

Returns a null CursorMut for this list.

source

pub fn cursor_owning(self) -> CursorOwning<A>

Returns a null CursorOwning for this list.

source

pub unsafe fn cursor_from_ptr( &self, ptr: *const <A::PointerOps as PointerOps>::Value ) -> Cursor<'_, A>

Creates a Cursor from a pointer to an element.

Safety

ptr must be a pointer to an object that is part of this list.

source

pub unsafe fn cursor_mut_from_ptr( &mut self, ptr: *const <A::PointerOps as PointerOps>::Value ) -> CursorMut<'_, A>

Creates a CursorMut from a pointer to an element.

Safety

ptr must be a pointer to an object that is part of this list.

source

pub unsafe fn cursor_owning_from_ptr( self, ptr: *const <A::PointerOps as PointerOps>::Value ) -> CursorOwning<A>

Creates a CursorOwning from a pointer to an element.

Safety

ptr must be a pointer to an object that is part of this list.

source

pub fn front(&self) -> Cursor<'_, A>

Returns a Cursor pointing to the first element of the list. If the list is empty then a null cursor is returned.

source

pub fn front_mut(&mut self) -> CursorMut<'_, A>

Returns a CursorMut pointing to the first element of the list. If the the list is empty then a null cursor is returned.

source

pub fn front_owning(self) -> CursorOwning<A>

Returns a CursorOwning pointing to the first element of the list. If the the list is empty then a null cursor is returned.

source

pub fn iter(&self) -> Iter<'_, A>

Gets an iterator over the objects in the SinglyLinkedList.

source

pub fn clear(&mut self)

Removes all elements from the SinglyLinkedList.

This will unlink all object currently in the list, which requires iterating through all elements in the SinglyLinkedList. Each element is converted back to an owned pointer and then dropped.

source

pub fn fast_clear(&mut self)

Empties the SinglyLinkedList without unlinking or freeing objects in it.

Since this does not unlink any objects, any attempts to link these objects into another SinglyLinkedList will fail but will not cause any memory unsafety. To unlink those objects manually, you must call the force_unlink function on them.

source

pub fn take(&mut self) -> SinglyLinkedList<A>where A: Clone,

Takes all the elements out of the SinglyLinkedList, leaving it empty. The taken elements are returned as a new SinglyLinkedList.

source

pub fn push_front(&mut self, val: <A::PointerOps as PointerOps>::Pointer)

Inserts a new element at the start of the SinglyLinkedList.

source

pub fn pop_front(&mut self) -> Option<<A::PointerOps as PointerOps>::Pointer>

Removes the first element of the SinglyLinkedList.

This returns None if the SinglyLinkedList is empty.

Trait Implementations§

source§

impl<A: Adapter> Debug for SinglyLinkedList<A>where A::LinkOps: SinglyLinkedListOps, <A::PointerOps as PointerOps>::Value: Debug,

source§

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

Formats the value using the given formatter. Read more
source§

impl<A: Adapter + Default> Default for SinglyLinkedList<A>where A::LinkOps: SinglyLinkedListOps,

source§

fn default() -> SinglyLinkedList<A>

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

impl<A: Adapter> Drop for SinglyLinkedList<A>where A::LinkOps: SinglyLinkedListOps,

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl<'a, A: Adapter + 'a> IntoIterator for &'a SinglyLinkedList<A>where A::LinkOps: SinglyLinkedListOps,

§

type Item = &'a <<A as Adapter>::PointerOps as PointerOps>::Value

The type of the elements being iterated over.
§

type IntoIter = Iter<'a, A>

Which kind of iterator are we turning this into?
source§

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

Creates an iterator from a value. Read more
source§

impl<A: Adapter> IntoIterator for SinglyLinkedList<A>where A::LinkOps: SinglyLinkedListOps,

§

type Item = <<A as Adapter>::PointerOps as PointerOps>::Pointer

The type of the elements being iterated over.
§

type IntoIter = IntoIter<A>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> IntoIter<A>

Creates an iterator from a value. Read more
source§

impl<A: Adapter + Send> Send for SinglyLinkedList<A>where <A::PointerOps as PointerOps>::Pointer: Send, A::LinkOps: SinglyLinkedListOps,

source§

impl<A: Adapter + Sync> Sync for SinglyLinkedList<A>where <A::PointerOps as PointerOps>::Value: Sync, A::LinkOps: SinglyLinkedListOps,

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.