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,

source

pub fn new() -> JostleTree<N, T>

source

pub fn is_empty(&self) -> bool

source

pub fn len(&self) -> usize

source

pub fn total_span(&self) -> N

returns the sum of the spans of all of the items (logarithmic runtime)

source

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.

source

pub fn insert_back<'a>(&'a mut self, span: N, v: T) -> SlotHandle<'a, N, T>

inserts at the back

source

pub fn insert_front<'a>(&'a mut self, span: N, v: T) -> SlotHandle<'a, N, T>

inserts at the front

source

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.

source

pub fn get_item(&self, o: N) -> Option<&T>

source

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.

source

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.

source

pub fn slot_iter<'a>(&'a self) -> JostleTreeIter<'a, N, T>

Iterates over the buckets

Trait Implementations§

source§

impl<N: Debug, T: Debug> Debug for JostleTree<N, T>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<N: Numeric + Display, T: Display> Display for JostleTree<N, T>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

impl<N, T> FromIterator<(N, T)> for JostleTree<N, T>
where N: Numeric,

source§

fn from_iter<I: IntoIterator<Item = (N, T)>>(iter: I) -> Self

Creates a value from an iterator. Read more
source§

impl<N: Numeric + Hash, T: Hash> Hash for JostleTree<N, T>

source§

fn hash<H: Hasher>(&self, h: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<N: Numeric, T: PartialEq> PartialEq for JostleTree<N, T>

source§

fn eq(&self, other: &JostleTree<N, T>) -> bool

This method tests for self and other values to be equal, and is used by ==.
source§

fn ne(&self, other: &JostleTree<N, T>) -> bool

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

Auto Trait Implementations§

§

impl<N, T> Freeze for JostleTree<N, T>

§

impl<N, T> RefUnwindSafe for JostleTree<N, T>

§

impl<N, T> !Send for JostleTree<N, T>

§

impl<N, T> !Sync for JostleTree<N, T>

§

impl<N, T> Unpin for JostleTree<N, T>

§

impl<N, T> UnwindSafe for JostleTree<N, T>

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> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

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

§

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

§

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.