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>
impl<C: TreapMapConfig> TreapMap<C>
pub fn new() -> TreapMap<C>
pub fn new_with_rng(rng: XorShiftRng) -> TreapMap<C>
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn contains_key(&self, key: &C::SearchKey) -> bool
pub fn insert( &mut self, key: C::SearchKey, value: C::Value, weight: C::Weight ) -> Option<C::Value>
pub fn remove(&mut self, key: &C::SearchKey) -> Option<C::Value>
sourcepub fn update<U, I, T, E>(
&mut self,
key: &C::SearchKey,
update: U,
insert: I
) -> Result<T, E>
pub fn update<U, I, T, E>( &mut self, key: &C::SearchKey, update: U, insert: I ) -> Result<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 anApplyOpOutcome<T>
or a custom errorE
. SeeApplyOpOutcome
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 aNode
) and should return a tuple containing a newNode<C>
and a value of typeT
, or an error of typeE
.- WARNING: The key of the new node must match the key provided to the function.
pub fn sum_weight(&self) -> C::Weight
pub fn get(&self, key: &C::SearchKey) -> Option<&C::Value>
pub fn get_by_weight(&self, weight: C::Weight) -> Option<&C::Value>
sourcepub fn search<F>(&self, f: F) -> Option<SearchResult<'_, C, C::Weight>>
pub fn search<F>(&self, f: F) -> Option<SearchResult<'_, C, C::Weight>>
See details in crate::accumulate_weight_search
sourcepub fn search_no_weight<F>(&self, f: F) -> Option<SearchResult<'_, C, NoWeight>>
pub fn search_no_weight<F>(&self, f: F) -> Option<SearchResult<'_, C, NoWeight>>
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.
pub fn iter(&self) -> Iter<'_, C> ⓘ
pub fn iter_range(&self, key: &C::SearchKey) -> Iter<'_, C> ⓘwhere
C: TreapMapConfig<SortKey = ()>,
pub fn values(&self) -> impl Iterator<Item = &C::Value>
pub fn key_values(&self) -> impl Iterator<Item = (&C::SearchKey, &C::Value)>
Trait Implementations§
Auto Trait Implementations§
impl<C> RefUnwindSafe for TreapMap<C>where
<C as TreapMapConfig>::ExtMap: RefUnwindSafe,
<C as TreapMapConfig>::SearchKey: RefUnwindSafe,
<C as TreapMapConfig>::SortKey: RefUnwindSafe,
<C as TreapMapConfig>::Value: RefUnwindSafe,
<C as TreapMapConfig>::Weight: RefUnwindSafe,
impl<C> Send for TreapMap<C>where
<C as TreapMapConfig>::ExtMap: Send,
<C as TreapMapConfig>::SearchKey: Send,
<C as TreapMapConfig>::SortKey: Send,
<C as TreapMapConfig>::Value: Send,
<C as TreapMapConfig>::Weight: Send,
impl<C> Sync for TreapMap<C>where
<C as TreapMapConfig>::ExtMap: Sync,
<C as TreapMapConfig>::SearchKey: Sync,
<C as TreapMapConfig>::SortKey: Sync,
<C as TreapMapConfig>::Value: Sync,
<C as TreapMapConfig>::Weight: Sync,
impl<C> Unpin for TreapMap<C>
impl<C> UnwindSafe for TreapMap<C>where
<C as TreapMapConfig>::ExtMap: UnwindSafe,
<C as TreapMapConfig>::SearchKey: UnwindSafe,
<C as TreapMapConfig>::SortKey: UnwindSafe,
<C as TreapMapConfig>::Value: UnwindSafe,
<C as TreapMapConfig>::Weight: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more