pub struct LearnedSet<K: Key> { /* private fields */ }Expand description
A sorted set backed by a learned index.
This is a thin wrapper around LearnedMap<K, ()>.
All operations take &self and are safe to call from multiple threads.
Implementations§
Source§impl<K: Key> LearnedSet<K>
impl<K: Key> LearnedSet<K>
Sourcepub fn with_config(config: Config) -> Self
pub fn with_config(config: Config) -> Self
Create a new set with the given configuration.
Sourcepub fn bulk_load(keys: &[K]) -> Result<Self>
pub fn bulk_load(keys: &[K]) -> Result<Self>
Create a set from sorted keys, deduplicating any repeated keys.
Keys must be in ascending order but duplicates are allowed and will be silently removed (sets are idempotent by definition).
§Errors
Returns an error if keys is empty (after dedup) or not sorted.
Sourcepub fn pin(&self) -> SetRef<'_, K>
pub fn pin(&self) -> SetRef<'_, K>
Pin the current epoch and return a SetRef convenience handle.
Sourcepub fn insert(&self, key: K, guard: &Guard) -> bool
pub fn insert(&self, key: K, guard: &Guard) -> bool
Insert a key. Returns true if the key was newly inserted.
Sourcepub fn remove(&self, key: &K, guard: &Guard) -> bool
pub fn remove(&self, key: &K, guard: &Guard) -> bool
Remove a key. Returns true if the key was present.
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Return the approximate number of elements in the set.
See LearnedMap::len for details on
relaxed-atomic staleness under concurrency.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Return true if the set is empty.
Subject to the same relaxed-atomic staleness as len.
Trait Implementations§
Source§impl<K: Key> Default for LearnedSet<K>
impl<K: Key> Default for LearnedSet<K>
Source§impl<K: Key> Extend<K> for LearnedSet<K>
impl<K: Key> Extend<K> for LearnedSet<K>
Source§fn extend<I: IntoIterator<Item = K>>(&mut self, iter: I)
fn extend<I: IntoIterator<Item = K>>(&mut self, iter: I)
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)