[−][src]Struct intrusive_collections::xor_linked_list::XorLinkedList
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
impl<A: Adapter> XorLinkedList<A> where
A::LinkOps: XorLinkedListOps,
[src]
A::LinkOps: XorLinkedListOps,
pub const fn new(adapter: A) -> XorLinkedList<A>
[src]
Creates an empty XorLinkedList
.
pub fn is_empty(&self) -> bool
[src]
Returns true
if the XorLinkedList
is empty.
pub fn cursor(&self) -> Cursor<A>
[src]
Returns a null Cursor
for this list.
pub fn cursor_mut(&mut self) -> CursorMut<A>
[src]
Returns a null CursorMut
for this list.
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>
[src]
&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)
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>
[src]
&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)
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>
[src]
&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)
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>
[src]
&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)
pub fn front(&self) -> Cursor<A>
[src]
Returns a Cursor
pointing to the first element of the list. If the
list is empty then a null cursor is returned.
pub fn front_mut(&mut self) -> CursorMut<A>
[src]
Returns a CursorMut
pointing to the first element of the list. If the
the list is empty then a null cursor is returned.
pub fn back(&self) -> Cursor<A>
[src]
Returns a Cursor
pointing to the last element of the list. If the list
is empty then a null cursor is returned.
pub fn back_mut(&mut self) -> CursorMut<A>
[src]
Returns a CursorMut
pointing to the last element of the list. If the
list is empty then a null cursor is returned.
pub fn iter(&self) -> Iter<A>
[src]
Gets an iterator over the objects in the XorLinkedList
.
pub fn clear(&mut self)
[src]
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.
pub fn fast_clear(&mut self)
[src]
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.
pub fn take(&mut self) -> XorLinkedList<A> where
A: Clone,
[src]
A: Clone,
Takes all the elements out of the XorLinkedList
, leaving it empty.
The taken elements are returned as a new XorLinkedList
.
pub fn push_front(&mut self, val: <A::PointerOps as PointerOps>::Pointer)
[src]
Inserts a new element at the start of the XorLinkedList
.
pub fn push_back(&mut self, val: <A::PointerOps as PointerOps>::Pointer)
[src]
Inserts a new element at the end of the XorLinkedList
.
pub fn pop_front(&mut self) -> Option<<A::PointerOps as PointerOps>::Pointer>
[src]
Removes the first element of the XorLinkedList
.
This returns None
if the XorLinkedList
is empty.
pub fn pop_back(&mut self) -> Option<<A::PointerOps as PointerOps>::Pointer>
[src]
Removes the last element of the XorLinkedList
.
This returns None
if the XorLinkedList
is empty.
pub fn reverse(&mut self)
[src]
Reverses the list in-place.
Due to the structure of XorLinkedList
, this operation is O(1).
Trait Implementations
impl<A: Adapter> Debug for XorLinkedList<A> where
A::LinkOps: XorLinkedListOps,
<A::PointerOps as PointerOps>::Value: Debug,
[src]
A::LinkOps: XorLinkedListOps,
<A::PointerOps as PointerOps>::Value: Debug,
impl<A: Adapter + Default> Default for XorLinkedList<A> where
A::LinkOps: XorLinkedListOps,
[src]
A::LinkOps: XorLinkedListOps,
fn default() -> XorLinkedList<A>
[src]
impl<A: Adapter> Drop for XorLinkedList<A> where
A::LinkOps: XorLinkedListOps,
[src]
A::LinkOps: XorLinkedListOps,
impl<A: Adapter> IntoIterator for XorLinkedList<A> where
A::LinkOps: XorLinkedListOps,
[src]
A::LinkOps: XorLinkedListOps,
type Item = <A::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?
fn into_iter(self) -> IntoIter<A>
[src]
impl<'a, A: Adapter + 'a> IntoIterator for &'a XorLinkedList<A> where
A::LinkOps: XorLinkedListOps,
[src]
A::LinkOps: XorLinkedListOps,
type Item = &'a <A::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?
fn into_iter(self) -> Iter<'a, A>
[src]
impl<A: Adapter + Send> Send for XorLinkedList<A> where
<A::PointerOps as PointerOps>::Pointer: Send,
A::LinkOps: XorLinkedListOps,
[src]
<A::PointerOps as PointerOps>::Pointer: Send,
A::LinkOps: XorLinkedListOps,
impl<A: Adapter + Sync> Sync for XorLinkedList<A> where
<A::PointerOps as PointerOps>::Value: Sync,
A::LinkOps: XorLinkedListOps,
[src]
<A::PointerOps as PointerOps>::Value: Sync,
A::LinkOps: XorLinkedListOps,
Auto Trait Implementations
impl<A> Unpin for XorLinkedList<A> where
A: Unpin,
<<A as Adapter>::LinkOps as LinkOps>::LinkPtr: Unpin,
A: Unpin,
<<A as Adapter>::LinkOps as LinkOps>::LinkPtr: Unpin,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<I> IntoIterator for I where
I: Iterator,
[src]
I: Iterator,
type Item = <I as Iterator>::Item
The type of the elements being iterated over.
type IntoIter = I
Which kind of iterator are we turning this into?
fn into_iter(self) -> I
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,