Struct cranelift_bforest::Set
source · pub struct Set<K>where
K: Copy,{ /* private fields */ }
Expand description
B-tree representing an ordered set of K
s using C
for comparing elements.
This is not a general-purpose replacement for BTreeSet
. See the module
documentation for more information about design tradeoffs.
Sets can be cloned, but that operation should only be used as part of cloning the whole forest they belong to. Cloning a set does not allocate new memory for the clone. It creates an alias of the same memory.
Implementations§
source§impl<K> Set<K>where
K: Copy,
impl<K> Set<K>where
K: Copy,
sourcepub fn contains<C: Comparator<K>>(
&self,
key: K,
forest: &SetForest<K>,
comp: &C,
) -> bool
pub fn contains<C: Comparator<K>>( &self, key: K, forest: &SetForest<K>, comp: &C, ) -> bool
Does the set contain key
?.
sourcepub fn insert<C: Comparator<K>>(
&mut self,
key: K,
forest: &mut SetForest<K>,
comp: &C,
) -> bool
pub fn insert<C: Comparator<K>>( &mut self, key: K, forest: &mut SetForest<K>, comp: &C, ) -> bool
Try to insert key
into the set.
If the set did not contain key
, insert it and return true.
If key
is already present, don’t change the set and return false.
sourcepub fn remove<C: Comparator<K>>(
&mut self,
key: K,
forest: &mut SetForest<K>,
comp: &C,
) -> bool
pub fn remove<C: Comparator<K>>( &mut self, key: K, forest: &mut SetForest<K>, comp: &C, ) -> bool
Remove key
from the set and return true.
If key
was not present in the set, return false.
sourcepub fn retain<F>(&mut self, forest: &mut SetForest<K>, predicate: F)
pub fn retain<F>(&mut self, forest: &mut SetForest<K>, predicate: F)
Retains only the elements specified by the predicate.
Remove all elements where the predicate returns false.
Trait Implementations§
Auto Trait Implementations§
impl<K> Freeze for Set<K>
impl<K> RefUnwindSafe for Set<K>where
K: RefUnwindSafe,
impl<K> Send for Set<K>where
K: Send,
impl<K> Sync for Set<K>where
K: Sync,
impl<K> Unpin for Set<K>where
K: Unpin,
impl<K> UnwindSafe for Set<K>where
K: 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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)