Struct BalancedBinaryTree

Source
pub struct BalancedBinaryTree<K: Ord, M: ActedMonoid> { /* private fields */ }
Expand description

平衡二分木

Implementations§

Source§

impl<K: Ord + Clone, M: ActedMonoid> BalancedBinaryTree<K, M>

Source

pub fn insert_lower(&mut self, key: K, val: M::Val)

key, val を挿入する(lowerbound 版)

  • 既存の同一 key は右側(>=)に送るので,新要素は「同一 key の先頭」に入る
Source

pub fn insert_upper(&mut self, key: K, val: M::Val)

key, val を挿入する(upperbound 版)

  • 既存の同一 key は左側(<=)に送るので,新要素は「同一 key の末尾」に入る
Source

pub fn insert_unique(&mut self, key: K, val: M::Val) -> bool

key がまだ存在しないときだけ (key, val) を挿入する

  • 返り値: 挿入できたら true, 既に存在していたら false
Source

pub fn remove(&mut self, key: &K) -> bool

key をもつ要素を削除する(存在すれば全て削除)

  • 返り値: 1 個以上削除できたら true
Source

pub fn get_range<R: RangeBounds<K> + Debug>(&mut self, range: R) -> M::Val

区間(key の範囲)の集約値を返す

Source

pub fn apply<R: RangeBounds<K> + Debug>(&mut self, range: R, act: M::Act)

区間(key の範囲)に作用を適用する

Source

pub fn is_empty(&self) -> bool

空であるか判定する

Source

pub fn len(&self) -> usize

要素数をカウントする

Trait Implementations§

Source§

impl<K: Ord, M: ActedMonoid> Default for BalancedBinaryTree<K, M>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<K, M> ShowBinaryTree<Ptr> for BalancedBinaryTree<K, M>
where K: Ord + Debug, M: ActedMonoid, M::Val: Debug, M::Act: Debug,

Source§

fn get_root(&self) -> Option<Ptr>

<required> 根を取得する
Source§

fn get_left(&self, ptr: &Ptr) -> Option<Ptr>

<required> 左の子のポインタを取得する
Source§

fn get_right(&self, ptr: &Ptr) -> Option<Ptr>

<required> 右の子のポインタを取得する
Source§

fn print_node(&self, ptr: &Ptr) -> String

<required> ノードの値を表示する
Source§

fn print_inner(&self, ptr: P, fill: &mut Vec<&'static str>, last: &'static str)

再帰的にprintを行う
Source§

fn print_as_binary_tree(&self)

2分木としてフォーマットする

Auto Trait Implementations§

§

impl<K, M> Freeze for BalancedBinaryTree<K, M>

§

impl<K, M> RefUnwindSafe for BalancedBinaryTree<K, M>

§

impl<K, M> Send for BalancedBinaryTree<K, M>
where K: Send, <M as ActedMonoid>::Val: Send, <M as ActedMonoid>::Act: Send,

§

impl<K, M> Sync for BalancedBinaryTree<K, M>
where K: Sync, <M as ActedMonoid>::Val: Sync, <M as ActedMonoid>::Act: Sync,

§

impl<K, M> Unpin for BalancedBinaryTree<K, M>
where K: Unpin, <M as ActedMonoid>::Val: Unpin, <M as ActedMonoid>::Act: Unpin,

§

impl<K, M> UnwindSafe for BalancedBinaryTree<K, 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V