Struct treap_map::TreapMap

source ·
pub struct TreapMap<C: TreapMapConfig> { /* private fields */ }
Expand description

A treap map data structure.

See TreapMapConfig for more details.

Implementations§

source§

impl<C: TreapMapConfig> TreapMap<C>

source

pub fn new() -> TreapMap<C>

source

pub fn new_with_rng(rng: XorShiftRng) -> TreapMap<C>

source

pub fn len(&self) -> usize

source

pub fn is_empty(&self) -> bool

source

pub fn contains_key(&self, key: &C::SearchKey) -> bool

source

pub fn insert( &mut self, key: C::SearchKey, value: C::Value, weight: C::Weight ) -> Option<C::Value>

source

pub fn remove(&mut self, key: &C::SearchKey) -> Option<C::Value>

source

pub fn update<U, I, T, E>( &mut self, key: &C::SearchKey, update: U, insert: I ) -> Result<T, E>
where U: FnOnce(&mut Node<C>) -> Result<ApplyOpOutcome<T>, E>, I: FnOnce(&mut dyn RngCore) -> Result<(Node<C>, T), E>,

Updates the value of a node with the given key in the treap map.

§Parameters
  • key: The search key of the node to be updated.
  • update: A function that is called if a node with the given key already exists. It takes a mutable reference to the node and returns an ApplyOpOutcome<T> or a custom error E. See ApplyOpOutcome for more details.
  • insert: A function that is called if a node with the given key does not exist. It takes a mutable reference to a random number generator (for computing priority for a Node) and should return a tuple containing a new Node<C> and a value of type T, or an error of type E.
    • WARNING: The key of the new node must match the key provided to the function.
source

pub fn sum_weight(&self) -> C::Weight

source

pub fn get(&self, key: &C::SearchKey) -> Option<&C::Value>

source

pub fn get_by_weight(&self, weight: C::Weight) -> Option<&C::Value>
where C::Weight: Ord,

source

pub fn search<F>(&self, f: F) -> Option<SearchResult<'_, C, C::Weight>>
where F: FnMut(&C::Weight, &Node<C>) -> SearchDirection<C::Weight>,

source

pub fn search_no_weight<F>(&self, f: F) -> Option<SearchResult<'_, C, NoWeight>>
where F: FnMut(&Node<C>) -> SearchDirection<()>,

See details in crate::accumulate_weight_search If the search process does not require accessing ‘weight’, this function can outperform search by eliminating the maintenance of the ‘weight’ dimension.

source

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

source

pub fn iter_range(&self, key: &C::SearchKey) -> Iter<'_, C>
where C: TreapMapConfig<SortKey = ()>,

source

pub fn values(&self) -> impl Iterator<Item = &C::Value>

source

pub fn key_values(&self) -> impl Iterator<Item = (&C::SearchKey, &C::Value)>

Trait Implementations§

source§

impl<C: TreapMapConfig> MallocSizeOf for TreapMap<C>
where Node<C>: MallocSizeOf, C::ExtMap: MallocSizeOf,

source§

fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize

Measure the heap usage of all descendant heap-allocated structures, but not the space taken up by the value itself.

Auto Trait Implementations§

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> Same for T

§

type Output = T

Should always be Self
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.
§

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

§

fn vzip(self) -> V