Struct Collection

Source
pub struct Collection<T, M>
where T: Val, M: Meta<T>,
{ pub root: Location<T, M>, pub stash: Stash<T, M>, pub divisor: usize, }
Expand description

A collection of elements of type T, with metadata of type M.

This is the base type, that all the collection operations are implemented over.

Fields§

§root: Location<T, M>

The location on the stash that constitutes the root for this collection.

§stash: Stash<T, M>

The store for values of type Node<T, M>

§divisor: usize

The branching factor, currently hard-coded to 2, which means on average every fourth element will have weight > 0.

Implementations§

Source§

impl<T, M> Collection<T, M>
where T: Val, M: Meta<T>,

Source

pub fn new() -> Self

Returns a new, empty Collection.

Source

pub fn new_from(root: Location<T, M>, stash: Stash<T, M>) -> Self

Constructs a Collection given a root and a stash

Source

pub fn _html(&self) -> String
where T: Debug,

Produces a html representation of this Collection. For debug use only.

Source

pub fn clone_mut(&mut self) -> Self

Clones the collection, mutating self

Source

pub fn union_using<F, E>(&mut self, b: &mut Self) -> Self
where F: Meta<T> + Select<T> + PartialEq + Ord, E: Meta<T> + PartialEq, M: SubMeta<F> + SubMeta<E>,

Returns a new, cloned collection that is the result of a union operation given two Meta implementations F and E

F is used to select which T goes first in the union.

E is used to find overlapping common subtrees.

For Sets: F: Max<T>, E: CheckSum<T>, and for Maps: F: Key<T::Key>, E: KeySum<T>.

When the equality testing succeeds, elements will be picked from the Collection b.

Source

pub fn mut_context<R: Relative>( &mut self, branch: Branch<T, M, R>, ) -> MutContext<'_, T, M, R>

Constructs a MutContext context, given a branch into the Collection.

Source§

impl<T, M> Collection<T, M>
where T: Val, M: Meta<T>,

Source

pub fn iter<'a>(&'a self) -> Iter<'a, T, M, Beginning>

Returns an iterator over Collection

Source

pub fn iter_rev<'a>(&'a self) -> Iter<'a, T, M, End>

Returns a reverse iterator over Collection

Trait Implementations§

Source§

impl<T, M> PartialEq for Collection<T, M>
where T: Val, M: Meta<T> + SubMeta<CheckSum<u64>>,

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Auto Trait Implementations§

§

impl<T, M> Freeze for Collection<T, M>

§

impl<T, M> RefUnwindSafe for Collection<T, M>

§

impl<T, M> Send for Collection<T, M>
where T: Send + Sync, M: Send + Sync,

§

impl<T, M> Sync for Collection<T, M>
where T: Sync + Send, M: Sync + Send,

§

impl<T, M> Unpin for Collection<T, M>
where T: Unpin, M: Unpin,

§

impl<T, M> UnwindSafe for Collection<T, M>

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, 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.