pub struct SetBy<K, F>{ /* private fields */ }Expand description
A simple set of keys, implemented using a splay tree.
This version allows a custom sorting function to be used.
Implementations§
Source§impl<K, F> SetBy<K, F>
impl<K, F> SetBy<K, F>
Sourcepub fn with_capacity(capacity: usize, compare: F) -> SetBy<K, F>
pub fn with_capacity(capacity: usize, compare: F) -> SetBy<K, F>
Constructor
Sourcepub fn reserve(&mut self, additional: usize)
pub fn reserve(&mut self, additional: usize)
Reserves capacity for at least additional more key/value pairs
Sourcepub fn get(&self, key: &K) -> Option<&K>
pub fn get(&self, key: &K) -> Option<&K>
Get a value by key.
If the key is not in the tree then None is returned.
Sourcepub fn set(&mut self, key: K) -> &K
pub fn set(&mut self, key: K) -> &K
Set a value by key.
set attempts to reconfigure the tree for future lookups by promoting the key to the top of
the tree.
Sourcepub fn unset(&mut self, key: &K) -> Option<&K>
pub fn unset(&mut self, key: &K) -> Option<&K>
Unset a value by key.
If the key does not exist, then this function has no effect.
Sourcepub fn iter(&self) -> SetByIterator<'_, K, F> ⓘ
pub fn iter(&self) -> SetByIterator<'_, K, F> ⓘ
Iterate over the key/value pairs in the Set
Trait Implementations§
Source§impl<'a, K, F> IntoIterator for &'a SetBy<K, F>
impl<'a, K, F> IntoIterator for &'a SetBy<K, F>
Auto Trait Implementations§
impl<K, F> !Freeze for SetBy<K, F>
impl<K, F> !RefUnwindSafe for SetBy<K, F>
impl<K, F> Send for SetBy<K, F>
impl<K, F> !Sync for SetBy<K, F>
impl<K, F> Unpin for SetBy<K, F>
impl<K, F> UnwindSafe for SetBy<K, F>where
F: UnwindSafe,
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
Mutably borrows from an owned value. Read more