Skip to main content

Treap

Struct Treap 

Source
pub struct Treap<T, R> { /* private fields */ }

Implementations§

Source§

impl<T, R> Treap<T, R>

Source

pub fn new(rng: R) -> Self

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn into_sorted_vec(self) -> Vec<T>

Source§

impl<T, R> Treap<T, R>
where T: Ord,

Source

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

集合にxが含まれるかを返す。

Source

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

xを削除する。集合にxが含まれていた場合trueを返す。

Source

pub fn le(&self, x: &T) -> Option<&T>

x以下の最大の要素を返す

Source

pub fn ge(&self, x: &T) -> Option<&T>

x以上の最小の要素を返す

Source

pub fn nth(&self, n: usize) -> Option<&T>

0-indexedでn番目の要素を返す

Source

pub fn position(&self, x: &T) -> Result<usize, usize>

xより小さい要素の個数を返す 集合がxを含む場合Ok, xを含まない場合Err

Source§

impl<T, R> Treap<T, R>
where T: Ord, R: RngCore,

Source

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

xを追加する。集合にxが含まれていなかった場合trueを返す。

Source§

impl<T, R> Treap<T, R>

Source

pub fn iter(&self) -> Iter<'_, T> ⓘ

Trait Implementations§

Source§

impl<T, R> Debug for Treap<T, R>
where T: Debug,

Source§

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

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

impl<T> Default for Treap<T, StdRng>

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl<T, R> Freeze for Treap<T, R>
where Option<Box<Node<T>>>: Freeze, R: Freeze,

§

impl<T, R> RefUnwindSafe for Treap<T, R>
where Option<Box<Node<T>>>: RefUnwindSafe, R: RefUnwindSafe,

§

impl<T, R> Send for Treap<T, R>
where Option<Box<Node<T>>>: Send, R: Send,

§

impl<T, R> Sync for Treap<T, R>
where Option<Box<Node<T>>>: Sync, R: Sync,

§

impl<T, R> Unpin for Treap<T, R>
where Option<Box<Node<T>>>: Unpin, R: Unpin,

§

impl<T, R> UnsafeUnpin for Treap<T, R>
where Option<Box<Node<T>>>: UnsafeUnpin, R: UnsafeUnpin,

§

impl<T, R> UnwindSafe for Treap<T, R>
where Option<Box<Node<T>>>: UnwindSafe, R: UnwindSafe,

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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.

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

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

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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