Struct makods::jostletree::JostleTree
source · pub struct JostleTree<N, T> { /* private fields */ }
Expand description
The JostleTree can be thought of as efficiently modeling a sequence of items of variable widths. It allows operations such as
-
jumping to a position and getting whatever item is there
-
resizing items, in so doing, repositioning every one of the items after it
-
inserting and removing
Operations generally have logarithmic runtime.
Implementations§
source§impl<N, T> JostleTree<N, T>where
N: Numeric,
impl<N, T> JostleTree<N, T>where
N: Numeric,
pub fn new() -> JostleTree<N, T>
pub fn is_empty(&self) -> bool
pub fn len(&self) -> usize
sourcepub fn total_span(&self) -> N
pub fn total_span(&self) -> N
returns the sum of the spans of all of the items (logarithmic runtime)
sourcepub fn insert_at<'a>(
&'a mut self,
at_offset: N,
span: N,
v: T
) -> SlotHandle<'a, N, T>
pub fn insert_at<'a>( &'a mut self, at_offset: N, span: N, v: T ) -> SlotHandle<'a, N, T>
inserts at or before whatever is at_offset.
sourcepub fn insert_back<'a>(&'a mut self, span: N, v: T) -> SlotHandle<'a, N, T>
pub fn insert_back<'a>(&'a mut self, span: N, v: T) -> SlotHandle<'a, N, T>
inserts at the back
sourcepub fn insert_front<'a>(&'a mut self, span: N, v: T) -> SlotHandle<'a, N, T>
pub fn insert_front<'a>(&'a mut self, span: N, v: T) -> SlotHandle<'a, N, T>
inserts at the front
sourcepub fn get_slot_mut<'a>(&'a mut self, o: N) -> Option<SlotHandle<'a, N, T>>
pub fn get_slot_mut<'a>(&'a mut self, o: N) -> Option<SlotHandle<'a, N, T>>
returns the bucket at the offset o
negative or out of bounds o values will get first and last thing respectively. returns None if tree is empty.
pub fn get_item(&self, o: N) -> Option<&T>
sourcepub fn remove_at(&mut self, o: N) -> Option<T>
pub fn remove_at(&mut self, o: N) -> Option<T>
negative or out of bounds o values will hit the first and last thing respectively. returns None if tree is empty.
sourcepub fn clear(&mut self)
pub fn clear(&mut self)
negative or out of bounds o values will get first and last thing respectively. returns None if tree is empty.
sourcepub fn slot_iter<'a>(&'a self) -> JostleTreeIter<'a, N, T> ⓘ
pub fn slot_iter<'a>(&'a self) -> JostleTreeIter<'a, N, T> ⓘ
Iterates over the buckets
Trait Implementations§
source§impl<N, T> FromIterator<(N, T)> for JostleTree<N, T>where
N: Numeric,
impl<N, T> FromIterator<(N, T)> for JostleTree<N, T>where
N: Numeric,
source§impl<N: Numeric, T: PartialEq> PartialEq for JostleTree<N, T>
impl<N: Numeric, T: PartialEq> PartialEq for JostleTree<N, T>
source§fn eq(&self, other: &JostleTree<N, T>) -> bool
fn eq(&self, other: &JostleTree<N, T>) -> bool
self
and other
values to be equal, and is used
by ==
.source§fn ne(&self, other: &JostleTree<N, T>) -> bool
fn ne(&self, other: &JostleTree<N, T>) -> bool
!=
. The default implementation is almost always
sufficient, and should not be overridden without very good reason.