pub struct XorLinkedList<A: Adapter>where
A::LinkOps: XorLinkedListOps,{ /* private fields */ }
Expand description
Intrusive xor doubly-linked list which uses less memory than a regular doubly linked list
In exchange for less memory use, it is impossible to create a cursor from a pointer to an element.
When this collection is dropped, all elements linked into it will be converted back to owned pointers and dropped.
Implementations§
source§impl<A: Adapter> XorLinkedList<A>where
A::LinkOps: XorLinkedListOps,
impl<A: Adapter> XorLinkedList<A>where
A::LinkOps: XorLinkedListOps,
sourcepub fn new(adapter: A) -> XorLinkedList<A>
pub fn new(adapter: A) -> XorLinkedList<A>
Creates an empty XorLinkedList
.
sourcepub fn cursor_mut(&mut self) -> CursorMut<'_, A>
pub fn cursor_mut(&mut self) -> CursorMut<'_, A>
Returns a null CursorMut
for this list.
sourcepub fn cursor_owning(self) -> CursorOwning<A>
pub fn cursor_owning(self) -> CursorOwning<A>
Returns a null CursorOwning
for this list.
sourcepub unsafe fn cursor_from_ptr_and_prev(
&self,
ptr: *const <A::PointerOps as PointerOps>::Value,
prev: *const <A::PointerOps as PointerOps>::Value,
) -> Cursor<'_, A>
pub unsafe fn cursor_from_ptr_and_prev( &self, ptr: *const <A::PointerOps as PointerOps>::Value, prev: *const <A::PointerOps as PointerOps>::Value, ) -> Cursor<'_, A>
Creates a Cursor
from a pointer to an element and a pointer to the previous element.
§Safety
ptr
must be a pointer to an object that is part of this list.
prev
must be a pointer to an object that is the previous object in this list (null for the head)
sourcepub unsafe fn cursor_mut_from_ptr_and_prev(
&mut self,
ptr: *const <A::PointerOps as PointerOps>::Value,
prev: *const <A::PointerOps as PointerOps>::Value,
) -> CursorMut<'_, A>
pub unsafe fn cursor_mut_from_ptr_and_prev( &mut self, ptr: *const <A::PointerOps as PointerOps>::Value, prev: *const <A::PointerOps as PointerOps>::Value, ) -> CursorMut<'_, A>
Creates a CursorMut
from a pointer to an element and a pointer to the previous element.
§Safety
ptr
must be a pointer to an object that is part of this list.
prev
must be a pointer to an object that is the previous object in this list (null for the head)
sourcepub unsafe fn cursor_owning_from_ptr_and_prev(
self,
ptr: *const <A::PointerOps as PointerOps>::Value,
prev: *const <A::PointerOps as PointerOps>::Value,
) -> CursorOwning<A>
pub unsafe fn cursor_owning_from_ptr_and_prev( self, ptr: *const <A::PointerOps as PointerOps>::Value, prev: *const <A::PointerOps as PointerOps>::Value, ) -> CursorOwning<A>
Creates a CursorOwning
from a pointer to an element and a pointer to the previous element.
§Safety
ptr
must be a pointer to an object that is part of this list.
prev
must be a pointer to an object that is the previous object in this list (null for the head)
sourcepub unsafe fn cursor_from_ptr_and_next(
&self,
ptr: *const <A::PointerOps as PointerOps>::Value,
next: *const <A::PointerOps as PointerOps>::Value,
) -> Cursor<'_, A>
pub unsafe fn cursor_from_ptr_and_next( &self, ptr: *const <A::PointerOps as PointerOps>::Value, next: *const <A::PointerOps as PointerOps>::Value, ) -> Cursor<'_, A>
Creates a Cursor
from a pointer to an element and a pointer to the next element.
§Safety
ptr
must be a pointer to an object that is part of this list.
next
must be a pointer to an object that is the next object in this list (null for the tail)
sourcepub unsafe fn cursor_mut_from_ptr_and_next(
&mut self,
ptr: *const <A::PointerOps as PointerOps>::Value,
next: *const <A::PointerOps as PointerOps>::Value,
) -> CursorMut<'_, A>
pub unsafe fn cursor_mut_from_ptr_and_next( &mut self, ptr: *const <A::PointerOps as PointerOps>::Value, next: *const <A::PointerOps as PointerOps>::Value, ) -> CursorMut<'_, A>
Creates a CursorMut
from a pointer to an element and a pointer to the next element.
§Safety
ptr
must be a pointer to an object that is part of this list.
next
must be a pointer to an object that is the next object in this list (null for the tail)
sourcepub unsafe fn cursor_owning_from_ptr_and_next(
self,
ptr: *const <A::PointerOps as PointerOps>::Value,
next: *const <A::PointerOps as PointerOps>::Value,
) -> CursorOwning<A>
pub unsafe fn cursor_owning_from_ptr_and_next( self, ptr: *const <A::PointerOps as PointerOps>::Value, next: *const <A::PointerOps as PointerOps>::Value, ) -> CursorOwning<A>
Creates a CursorOwning
from a pointer to an element and a pointer to the next element.
§Safety
ptr
must be a pointer to an object that is part of this list.
next
must be a pointer to an object that is the next object in this list (null for the tail)
sourcepub fn front(&self) -> Cursor<'_, A>
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.
sourcepub fn front_mut(&mut self) -> CursorMut<'_, A>
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.
sourcepub fn front_owning(self) -> CursorOwning<A>
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.
sourcepub fn back(&self) -> Cursor<'_, A>
pub fn back(&self) -> Cursor<'_, A>
Returns a Cursor
pointing to the last element of the list. If the list
is empty then a null cursor is returned.
sourcepub fn back_mut(&mut self) -> CursorMut<'_, A>
pub fn back_mut(&mut self) -> CursorMut<'_, A>
Returns a CursorMut
pointing to the last element of the list. If the
list is empty then a null cursor is returned.
sourcepub fn back_owning(self) -> CursorOwning<A>
pub fn back_owning(self) -> CursorOwning<A>
Returns a CursorOwning
pointing to the last element of the list. If the
list is empty then a null cursor is returned.
sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Removes all elements from the XorLinkedList
.
This will unlink all object currently in the list, which requires
iterating through all elements in the XorLinkedList
. Each element is
converted back to an owned pointer and then dropped.
sourcepub fn fast_clear(&mut self)
pub fn fast_clear(&mut self)
Empties the XorLinkedList
without unlinking or freeing objects in it.
Since this does not unlink any objects, any attempts to link these
objects into another XorLinkedList
will fail but will not cause any
memory unsafety. To unlink those objects manually, you must call the
force_unlink
function on them.
sourcepub fn take(&mut self) -> XorLinkedList<A>where
A: Clone,
pub fn take(&mut self) -> XorLinkedList<A>where
A: Clone,
Takes all the elements out of the XorLinkedList
, leaving it empty.
The taken elements are returned as a new XorLinkedList
.
sourcepub fn push_front(&mut self, val: <A::PointerOps as PointerOps>::Pointer)
pub fn push_front(&mut self, val: <A::PointerOps as PointerOps>::Pointer)
Inserts a new element at the start of the XorLinkedList
.
sourcepub fn push_back(&mut self, val: <A::PointerOps as PointerOps>::Pointer)
pub fn push_back(&mut self, val: <A::PointerOps as PointerOps>::Pointer)
Inserts a new element at the end of the XorLinkedList
.
sourcepub fn pop_front(&mut self) -> Option<<A::PointerOps as PointerOps>::Pointer>
pub fn pop_front(&mut self) -> Option<<A::PointerOps as PointerOps>::Pointer>
Removes the first element of the XorLinkedList
.
This returns None
if the XorLinkedList
is empty.
sourcepub fn pop_back(&mut self) -> Option<<A::PointerOps as PointerOps>::Pointer>
pub fn pop_back(&mut self) -> Option<<A::PointerOps as PointerOps>::Pointer>
Removes the last element of the XorLinkedList
.
This returns None
if the XorLinkedList
is empty.