Struct SplayTree

Source
pub struct SplayTree<M: Monoid> { /* private fields */ }
Expand description

スプレーツリー

Implementations§

Source§

impl<M: Monoid + Clone> SplayTree<M>

Source

pub fn new() -> Self

モノイドmをもつSplayTree<M>を生成

Source

pub fn singleton(value: M) -> Self

valueをもつノード一つのみからなるSplayTree<M>を生成

Source

pub fn len(&self) -> usize

スプレーツリーの要素数を返す

Source

pub fn is_empty(&self) -> bool

スプレーツリーが要素を持たなければtrueを返す

Source

pub fn get(&self, index: usize) -> Option<&M>

index番目の要素の参照を返す

Source

pub fn set(&mut self, index: usize, value: M)

index番目の要素をvalueに変更する

Source

pub fn merge_right(&mut self, right: Self)

右側にスプレーツリーを結合する

Source

pub fn merge_left(&mut self, left: Self)

左側にスプレーツリーを結合する

Source

pub fn split(self, index: usize) -> (Self, Self)

左側にindex個の要素があるように、左右で分割する

Source

pub fn insert(&mut self, index: usize, value: M)

要素をindex番目になるように挿入する

Source

pub fn remove(&mut self, index: usize) -> Option<M>

index番目の要素を削除して、値を返す

Source

pub fn reverse(&mut self, _: Range<usize>)

start..endの範囲を反転させる

Source

pub fn fold(&self, _: Range<usize>) -> M

start..endの範囲でのモノイドの演算の結果を返す

Source

pub fn push_first(&mut self, value: M)

先頭に値を追加する

Source

pub fn push_last(&mut self, value: M)

末尾に値を追加する

Source

pub fn pop_first(&mut self) -> Option<M>

先頭の値を削除する

Source

pub fn pop_last(&mut self) -> Option<M>

末尾の値を削除する

Source

pub fn for_each(&self, f: impl FnMut(&M))

列の要素を始めから辿り、その参照をfに渡す。

Trait Implementations§

Source§

impl<M: Monoid + Clone> Default for SplayTree<M>

Source§

fn default() -> Self

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

impl<M: Monoid> Drop for SplayTree<M>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<M> !Freeze for SplayTree<M>

§

impl<M> !RefUnwindSafe for SplayTree<M>

§

impl<M> !Send for SplayTree<M>

§

impl<M> !Sync for SplayTree<M>

§

impl<M> Unpin for SplayTree<M>

§

impl<M> UnwindSafe for SplayTree<M>
where M: RefUnwindSafe,

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