Struct CoreCol

Source
pub struct CoreCol<V, P>
where V: Variant, P: PinnedVec<Node<V>>,
{ /* private fields */ }
Expand description

Core collection of the self referential collection.

Implementations§

Source§

impl<V, P> CoreCol<V, P>
where V: Variant, P: PinnedVec<Node<V>>,

Source

pub fn new() -> Self
where P: Default,

Creates a new empty collection.

Source

pub fn into_inner(self) -> (P, V::Ends, usize)

Destructs the collection into its inner pinned vec, ends and length.

Source

pub fn utilization(&self) -> Utilization

Returns current node utilization of the collection.

Source

pub fn len(&self) -> usize

Returns length of the self referential collection.

Source

pub fn is_empty(&self) -> bool

Returns whether or not the self referential collection is empty.

Source

pub fn nodes(&self) -> &P

Returns a reference to the underlying nodes storage.

Source

pub fn node(&self, node_ptr: &NodePtr<V>) -> &Node<V>

Returns a reference to the node with the given node_ptr.

Source

pub fn position_of(&self, node_ptr: &NodePtr<V>) -> Option<usize>

Returns the position of the node with the given node_ptr, None if the pointer is not valid.

Source

pub fn position_of_unchecked(&self, node_ptr: &NodePtr<V>) -> usize

Returns the position of the node with the given node_ptr.

§Panics

Panics if the pointer is not valid.

Source

pub unsafe fn data_unchecked(&self, node_ptr: &NodePtr<V>) -> &V::Item

Returns a reference to the data.

§Panics

Panics if the node is already closed.

§Safety

Does not perform bounds check; hence, the caller must guarantee that the node_ptr belongs to (created from) this collection.

Source

pub fn ends(&self) -> &V::Ends

Returns a reference to the ends of the collection.

Source

pub fn node_ptr_at_pos(&self, node_position: usize) -> NodePtr<V>

Returns the pointer of the element with the given node_position in the underlying nodes storage.

§Panics

Panics if the node_position is out of bounds.

Source

pub fn nodes_mut(&mut self) -> &mut P

Returns a mutable reference to the underlying nodes storage.

Source

pub fn push(&mut self, data: V::Item) -> NodePtr<V>

Pushes the element with the given data and returns its pointer.

Source

pub unsafe fn data_mut_unchecked( &mut self, node_ptr: &NodePtr<V>, ) -> &mut V::Item

Returns a mutable reference to the data.

§Panics

Panics if the node is already closed.

§Safety

Does not perform bounds check; hence, the caller must guarantee that the node_ptr belongs to (created from) this collection.

Source

pub fn close(&mut self, node_ptr: &NodePtr<V>) -> V::Item

Closes the node at the given node_ptr and returns its data.

§Panics

Panics if the node was already closed.

Source

pub fn close_if_active(&mut self, node_ptr: &NodePtr<V>) -> Option<V::Item>

Closes the node at the given node_ptr and returns its data the node was active. Does nothing and returns None if the node was already closed.

Source

pub fn ends_mut(&mut self) -> &mut V::Ends

Returns a mutable reference to the ends of the collection.

Source

pub fn node_mut(&mut self, node_ptr: &NodePtr<V>) -> &mut Node<V>

Returns a mutable reference to the node with the given node_ptr.

Source

pub fn move_node(&mut self, closed_position: usize, active_position: usize)

Swaps the closed node at the closed_position with the active node at the active_position.

Source

pub fn swap_data( &mut self, node_ptr: &NodePtr<V>, new_value: V::Item, ) -> V::Item

Swaps the underlying data of the element at the given node_ptr with the new_value, and returns the old value.

§Panics

Panics if the node was already closed.

Source§

impl<V> CoreCol<V, SplitVec<Node<V>, Recursive>>
where V: Variant,

Source

pub fn append_nodes(&mut self, nodes: SplitVec<Node<V>, Recursive>)

Appends the nodes to this collection.

Trait Implementations§

Source§

impl<V, P> Default for CoreCol<V, P>
where V: Variant, P: PinnedVec<Node<V>> + Default,

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl<V, P> Freeze for CoreCol<V, P>
where P: Freeze, <V as Variant>::Ends: Freeze,

§

impl<V, P> RefUnwindSafe for CoreCol<V, P>

§

impl<V, P> Send for CoreCol<V, P>
where P: Send, <V as Variant>::Ends: Send,

§

impl<V, P> Sync for CoreCol<V, P>
where P: Sync, <V as Variant>::Ends: Sync,

§

impl<V, P> Unpin for CoreCol<V, P>
where P: Unpin, <V as Variant>::Ends: Unpin,

§

impl<V, P> UnwindSafe for CoreCol<V, P>
where P: UnwindSafe, <V as Variant>::Ends: UnwindSafe,

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where 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 T
where 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> SoM<T> for T

Source§

fn get_ref(&self) -> &T

Returns a reference to self.
Source§

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

Returns a mutable reference to self.
Source§

impl<T> SoR<T> for T

Source§

fn get_ref(&self) -> &T

Returns a reference to self.
Source§

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

Source§

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 T
where U: TryFrom<T>,

Source§

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.