pub struct BicrementalMedian<T: Ord + Clone> { /* private fields */ }
Expand description

中央値の管理。

多重集合への要素の追加と削除を行いつつ、中央値を管理する。

Naming

incremental と decremental の双方向の処理を行うので、bidirectional の気持ちで bicremental とした。記憶が正しければえびちゃんの造語なので、 もっとよい名前があれば変えたい。dynamic は意味が曖昧なのできらい。

Notes

集合に $k$ 個追加・削除する操作をサポートできないか?と思ったが、 これだと計算量の保証ができない。$\{\{1, 2, \dots, n\}\}$ に対して $0$ を $n$ 個追加する操作と、$0$ を $n$ 個削除する操作を繰り返すことで、 簡単に worst $\Omega(n)$ 時間になってしまう。

Implementations§

source§

impl<T: Ord + Clone> BicrementalMedian<T>

source

pub fn new() -> Self

source

pub fn insert(&mut self, x: T)

source

pub fn remove(&mut self, x: &T) -> bool

source

pub fn median(&self) -> Option<&T>

Trait Implementations§

source§

impl<T: Clone + Ord + Clone> Clone for BicrementalMedian<T>

source§

fn clone(&self) -> BicrementalMedian<T>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<T: Debug + Ord + Clone> Debug for BicrementalMedian<T>

source§

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

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

impl<T: PartialEq + Ord + Clone> PartialEq<BicrementalMedian<T>> for BicrementalMedian<T>

source§

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

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

fn ne(&self, other: &Rhs) -> bool

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

impl<T: Eq + Ord + Clone> Eq for BicrementalMedian<T>

source§

impl<T: Ord + Clone> StructuralEq for BicrementalMedian<T>

source§

impl<T: Ord + Clone> StructuralPartialEq for BicrementalMedian<T>

Auto Trait Implementations§

§

impl<T> RefUnwindSafe for BicrementalMedian<T>where T: RefUnwindSafe,

§

impl<T> Send for BicrementalMedian<T>where T: Send,

§

impl<T> Sync for BicrementalMedian<T>where T: Sync,

§

impl<T> Unpin for BicrementalMedian<T>

§

impl<T> UnwindSafe for BicrementalMedian<T>where T: RefUnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere 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 Twhere 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.
§

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

§

fn vzip(self) -> V