Skip to main content

SortableWeave

Trait SortableWeave 

Source
pub trait SortableWeave<K, N, T>: Weave<K, N, T>
where K: Hash + Copy + Eq + Ord, N: Node<K, T>,
{ // Required methods fn sort_children_by( &mut self, id: &K, cmp: impl FnMut(&N, &N) -> Ordering, ) -> bool; fn sort_children_by_id( &mut self, id: &K, cmp: impl FnMut(&K, &K) -> Ordering, ) -> bool; fn sort_roots_by(&mut self, cmp: impl FnMut(&N, &N) -> Ordering); fn sort_roots_by_id(&mut self, cmp: impl FnMut(&K, &K) -> Ordering); }
Expand description

A Weave where the ordering of nodes is stable and can be user-defined.

§Panics

All panics should be assumed to leave the Weave in a malformed state unless otherwise specified by the implementation.

Required Methods§

Source

fn sort_children_by( &mut self, id: &K, cmp: impl FnMut(&N, &N) -> Ordering, ) -> bool

Sorts the child nodes of a parent node with the specified identifier using the comparison function cmp.

§Panics

May panic if cmp does not implement a total order, or if cmp itself panics.

Source

fn sort_children_by_id( &mut self, id: &K, cmp: impl FnMut(&K, &K) -> Ordering, ) -> bool

Sorts the identifiers of a parent node’s children with the specified identifier using the comparison function cmp.

§Panics

May panic if cmp does not implement a total order, or if cmp itself panics.

Source

fn sort_roots_by(&mut self, cmp: impl FnMut(&N, &N) -> Ordering)

Sorts root nodes (nodes which do not have any parents) using the comparison function cmp.

§Panics

May panic if cmp does not implement a total order, or if cmp itself panics.

Source

fn sort_roots_by_id(&mut self, cmp: impl FnMut(&K, &K) -> Ordering)

Sorts the identifiers of root nodes (nodes which do not have any parents) using the comparison function cmp.

§Panics

May panic if cmp does not implement a total order, or if cmp itself panics.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<K, T, M, S> SortableWeave<K, DependentNode<K, T, S>, T> for DependentWeave<K, T, M, S>
where K: Hash + Copy + Eq + Ord, S: BuildHasher + Default + Clone,

Source§

impl<K, T, M, S> SortableWeave<K, IndependentNode<K, T, S>, T> for IndependentWeave<K, T, M, S>

Source§

impl<W, K, N, T, M> SortableWeave<K, N, T> for LoggedWeave<W, K, N, T, M>
where W: SortableWeave<K, N, T>, K: Hash + Copy + Eq + Ord, N: Node<K, T> + Clone, for<'a> &'a N::To: IntoIterator<Item = &'a K>, for<'a> &'a W::Roots: IntoIterator<Item = &'a K>,

Source§

impl<W, K, N, T, S> SortableWeave<K, N, T> for DeduplicatedWeave<W, K, N, T, S>
where W: SortableWeave<K, N, T>, K: Hash + Copy + Eq + Ord, T: DeduplicatableContents, N: Node<K, T>, S: BuildHasher + Default + Clone, for<'a> &'a W::Roots: IntoIterator<Item = &'a K>, for<'a> &'a N::From: IntoIterator<Item = &'a K>, for<'a> &'a N::To: IntoIterator<Item = &'a K>,

Source§

impl<W, K, N, T> SortableWeave<K, N, T> for CountedWeave<W, K, N, T>
where W: SortableWeave<K, N, T>, K: Hash + Copy + Eq + Ord, N: Node<K, T>,