Enum im_ternary_tree::TernaryTreeList
source · [−]pub enum TernaryTreeList<T> {
Empty,
Tree(TernaryTree<T>),
}
Expand description
wraps TerarnaryTreeList with support for empty
Variants
Empty
Tree(TernaryTree<T>)
Implementations
sourceimpl<T> TernaryTreeList<T> where
T: Clone + Display + Eq + PartialEq + Debug + Ord + PartialOrd + Hash,
impl<T> TernaryTreeList<T> where
T: Clone + Display + Eq + PartialEq + Debug + Ord + PartialOrd + Hash,
pub fn is_empty(&self) -> bool
pub fn len(&self) -> usize
sourcepub fn format_inline(&self) -> String
pub fn format_inline(&self) -> String
turn into a representation in triples, _
for holes
sourcepub fn get(&self, idx: usize) -> Option<&T>
pub fn get(&self, idx: usize) -> Option<&T>
get element in list by reference
PERF: recursive function is slower than iterative loop with Cell in bench(using usize
),
however, Calcit is heavy in cloning(reference though… according real practice),
so here we still choose ref_get
for speed in Calcit project.
sourcepub fn find_index(&self, f: Arc<dyn Fn(&T) -> bool>) -> Option<i64>
pub fn find_index(&self, f: Arc<dyn Fn(&T) -> bool>) -> Option<i64>
find position of matched element in list(if exists)
sourcepub fn loop_get(&self, original_idx: usize) -> Option<&T>
pub fn loop_get(&self, original_idx: usize) -> Option<&T>
unchecked get via go down the branch with a mutable loop
this function is SLOWER compared to ref_get
, not used by default
pub fn first(&self) -> Option<&T>
pub fn last(&self) -> Option<&T>
pub fn assoc(&self, idx: usize, item: T) -> Result<Self, String>
pub fn dissoc(&self, idx: usize) -> Result<Self, String>
pub fn butlast(&self) -> Result<Self, String>
pub fn insert(&self, idx: usize, item: T, after: bool) -> Result<Self, String>
pub fn assoc_before(&self, idx: usize, item: T) -> Result<Self, String>
pub fn assoc_after(&self, idx: usize, item: T) -> Result<Self, String>
pub fn force_inplace_balancing(&mut self) -> Result<(), String>
pub fn unshift(&self, item: T) -> Self
pub fn prepend(&self, item: T) -> Self
pub fn push(&self, item: T) -> Self
sourcepub fn append(&self, item: T) -> Self
pub fn append(&self, item: T) -> Self
insert_after last element, this not optimzed for performance
sourcepub fn push_right(&self, item: T) -> Self
pub fn push_right(&self, item: T) -> Self
optimized for amortized O(1)
performance at best cases
sourcepub fn push_left(&self, item: T) -> Self
pub fn push_left(&self, item: T) -> Self
optimized for amortized O(1)
performance at best cases
pub fn drop_left(&self) -> Self
sourcepub fn drop_left_shallow(&self) -> Self
pub fn drop_left_shallow(&self) -> Self
optimized for amortized O(1)
at best cases, but copies a lot
pub fn drop_right(&self) -> Self
sourcepub fn drop_right_shallow(&self) -> Self
pub fn drop_right_shallow(&self) -> Self
optimized for amortized O(1)
at best cases, but copies a lot
pub fn concat(raw: &[TernaryTreeList<T>]) -> Self
pub fn check_structure(&self) -> Result<(), String>
pub fn slice(&self, start_idx: usize, end_idx: usize) -> Result<Self, String>
pub fn skip(&self, idx: usize) -> Result<Self, String>
pub fn take(&self, idx: usize) -> Result<Self, String>
pub fn reverse(&self) -> Self
pub fn map<V>(&self, f: Arc<dyn Fn(&T) -> V>) -> TernaryTreeList<V>
pub fn to_vec(&self) -> Vec<T>
pub fn iter(&self) -> TernaryTreeListRefIntoIterator<'_, T>ⓘNotable traits for TernaryTreeListRefIntoIterator<'a, T>impl<'a, T> Iterator for TernaryTreeListRefIntoIterator<'a, T> where
T: Clone + Display + Eq + PartialEq + Debug + Ord + PartialOrd + Hash, type Item = &'a T;
T: Clone + Display + Eq + PartialEq + Debug + Ord + PartialOrd + Hash, type Item = &'a T;
Trait Implementations
sourceimpl<T: Clone> Clone for TernaryTreeList<T>
impl<T: Clone> Clone for TernaryTreeList<T>
sourcefn clone(&self) -> TernaryTreeList<T>
fn clone(&self) -> TernaryTreeList<T>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl<T: Debug> Debug for TernaryTreeList<T>
impl<T: Debug> Debug for TernaryTreeList<T>
sourceimpl<T> Display for TernaryTreeList<T> where
T: Clone + Display + Eq + PartialEq + Debug + Ord + PartialOrd + Hash,
impl<T> Display for TernaryTreeList<T> where
T: Clone + Display + Eq + PartialEq + Debug + Ord + PartialOrd + Hash,
sourceimpl<T, const N: usize> From<&[T; N]> for TernaryTreeList<T> where
T: Clone + Display + Eq + PartialEq + Debug + Ord + PartialOrd + Hash,
impl<T, const N: usize> From<&[T; N]> for TernaryTreeList<T> where
T: Clone + Display + Eq + PartialEq + Debug + Ord + PartialOrd + Hash,
sourceimpl<T> From<&Vec<T, Global>> for TernaryTreeList<T> where
T: Clone + Display + Eq + PartialEq + Debug + Ord + PartialOrd + Hash,
impl<T> From<&Vec<T, Global>> for TernaryTreeList<T> where
T: Clone + Display + Eq + PartialEq + Debug + Ord + PartialOrd + Hash,
sourceimpl<T> From<Vec<T, Global>> for TernaryTreeList<T> where
T: Clone + Display + Eq + PartialEq + Debug + Ord + PartialOrd + Hash,
impl<T> From<Vec<T, Global>> for TernaryTreeList<T> where
T: Clone + Display + Eq + PartialEq + Debug + Ord + PartialOrd + Hash,
sourceimpl<T> Hash for TernaryTreeList<T> where
T: Clone + Display + Eq + PartialEq + Debug + Ord + PartialOrd + Hash,
impl<T> Hash for TernaryTreeList<T> where
T: Clone + Display + Eq + PartialEq + Debug + Ord + PartialOrd + Hash,
sourceimpl<T> Index<usize> for TernaryTreeList<T> where
T: Clone + Display + Eq + PartialEq + Debug + Ord + PartialOrd + Hash,
impl<T> Index<usize> for TernaryTreeList<T> where
T: Clone + Display + Eq + PartialEq + Debug + Ord + PartialOrd + Hash,
sourceimpl<'a, T> IntoIterator for &'a TernaryTreeList<T> where
T: Clone + Display + Eq + PartialEq + Debug + Ord + PartialOrd + Hash,
impl<'a, T> IntoIterator for &'a TernaryTreeList<T> where
T: Clone + Display + Eq + PartialEq + Debug + Ord + PartialOrd + Hash,
sourceimpl<T> Ord for TernaryTreeList<T> where
T: Clone + Display + Eq + PartialEq + Debug + Ord + PartialOrd + Hash,
impl<T> Ord for TernaryTreeList<T> where
T: Clone + Display + Eq + PartialEq + Debug + Ord + PartialOrd + Hash,
sourceimpl<T: Clone + Display + Eq + PartialEq + Debug + Ord + PartialOrd + Hash> PartialEq<TernaryTreeList<T>> for TernaryTreeList<T>
impl<T: Clone + Display + Eq + PartialEq + Debug + Ord + PartialOrd + Hash> PartialEq<TernaryTreeList<T>> for TernaryTreeList<T>
sourceimpl<T> PartialOrd<TernaryTreeList<T>> for TernaryTreeList<T> where
T: Clone + Display + Eq + PartialEq + Debug + Ord + PartialOrd + Hash,
impl<T> PartialOrd<TernaryTreeList<T>> for TernaryTreeList<T> where
T: Clone + Display + Eq + PartialEq + Debug + Ord + PartialOrd + Hash,
sourcefn partial_cmp(&self, other: &Self) -> Option<Ordering>
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
impl<T> Eq for TernaryTreeList<T> where
T: Clone + Display + Eq + PartialEq + Debug + Ord + PartialOrd + Hash,
Auto Trait Implementations
impl<T> RefUnwindSafe for TernaryTreeList<T> where
T: RefUnwindSafe,
impl<T> Send for TernaryTreeList<T> where
T: Send + Sync,
impl<T> Sync for TernaryTreeList<T> where
T: Send + Sync,
impl<T> Unpin for TernaryTreeList<T>
impl<T> UnwindSafe for TernaryTreeList<T> where
T: RefUnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more