pub struct BLinkSet<T, const N: usize = DEFAULT_PAGE_CAPACITY> { /* private fields */ }Expand description
A concurrent ordered set backed by BLinkMap.
Values are stored as map keys with zero-sized () payloads, so the set has
the same page-latch concurrency, fence correction, split, merge, and memory
reclamation behavior as the map. N is the maximum stable records or
separators per page and defaults to DEFAULT_PAGE_CAPACITY.
Lookup and iteration return SetRef guards rather than bare references.
Each guard read-locks its whole leaf; drop it before a conflicting operation
on the same part of the set.
Implementations§
Source§impl<T, const N: usize> BLinkSet<T, N>
impl<T, const N: usize> BLinkSet<T, N>
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates an empty set.
§Panics
Panics under the same invalid-capacity and allocation conditions as
BLinkMap::new.
Examples found in repository?
3fn main() {
4 let map = BLinkMap::<u64, String>::new();
5 map.insert(7, String::from("seven"));
6
7 let set = BLinkSet::<u64>::new();
8 set.insert(7);
9
10 let value = map.get(&7).expect("the example inserted key 7");
11
12 println!(
13 "map[7] = {}, set contains 7 = {}",
14 value.value(),
15 set.contains(&7)
16 );
17}Source§impl<T: Ord, const N: usize> BLinkSet<T, N>
impl<T: Ord, const N: usize> BLinkSet<T, N>
Sourcepub fn contains<Q>(&self, value: &Q) -> bool
pub fn contains<Q>(&self, value: &Q) -> bool
Returns true when an ordering-compatible borrowed value is present.
Examples found in repository?
3fn main() {
4 let map = BLinkMap::<u64, String>::new();
5 map.insert(7, String::from("seven"));
6
7 let set = BLinkSet::<u64>::new();
8 set.insert(7);
9
10 let value = map.get(&7).expect("the example inserted key 7");
11
12 println!(
13 "map[7] = {}, set contains 7 = {}",
14 value.value(),
15 set.contains(&7)
16 );
17}Sourcepub fn get<Q>(&self, value: &Q) -> Option<SetRef<'_, T, N>>
pub fn get<Q>(&self, value: &Q) -> Option<SetRef<'_, T, N>>
Returns a guard for the stored value equal to value.
Sourcepub fn insert(&self, value: T) -> bool
pub fn insert(&self, value: T) -> bool
Inserts value, returning true only when it was not already present.
Examples found in repository?
3fn main() {
4 let map = BLinkMap::<u64, String>::new();
5 map.insert(7, String::from("seven"));
6
7 let set = BLinkSet::<u64>::new();
8 set.insert(7);
9
10 let value = map.get(&7).expect("the example inserted key 7");
11
12 println!(
13 "map[7] = {}, set contains 7 = {}",
14 value.value(),
15 set.contains(&7)
16 );
17}Sourcepub fn remove<Q>(&self, value: &Q) -> bool
pub fn remove<Q>(&self, value: &Q) -> bool
Removes value, returning true only when a record was present.
Deletion performs the map’s complete borrow/merge/unlink/root-collapse protocol; it does not leave empty non-root leaf pages behind. A removed value that remains useful as a routing fence may keep its allocation alive until that fence changes or the set is dropped.
Sourcepub fn iter(&self) -> SetIter<'_, T, N> ⓘ
pub fn iter(&self) -> SetIter<'_, T, N> ⓘ
Returns a weakly consistent ascending iterator over guarded values.
Sourcepub fn range<Q, R>(&self, bounds: R) -> SetRange<'_, T, Q, R, N> ⓘ
pub fn range<Q, R>(&self, bounds: R) -> SetRange<'_, T, Q, R, N> ⓘ
Returns a weakly consistent ascending iterator over bounds.
§Panics
Panics for an inverted range or equal bounds that are both excluded.
Sourcepub fn is_disjoint(&self, other: &Self) -> bool
pub fn is_disjoint(&self, other: &Self) -> bool
Returns true when this set and other share no value.
Concurrent mutation makes this a weakly consistent traversal rather than a transaction spanning both sets.
Sourcepub fn is_subset(&self, other: &Self) -> bool
pub fn is_subset(&self, other: &Self) -> bool
Returns true when every observed value in this set is in other.
Concurrent mutation makes this a weakly consistent traversal rather than an atomic relation between two sets.
Sourcepub fn is_superset(&self, other: &Self) -> bool
pub fn is_superset(&self, other: &Self) -> bool
Returns true when every observed value in other is in this set.
Trait Implementations§
impl<T: Ord, const N: usize> Eq for BLinkSet<T, N>
Source§impl<T: Ord, const N: usize> Extend<T> for BLinkSet<T, N>
impl<T: Ord, const N: usize> Extend<T> for BLinkSet<T, N>
Source§fn extend<I: IntoIterator<Item = T>>(&mut self, iterable: I)
fn extend<I: IntoIterator<Item = T>>(&mut self, iterable: I)
Inserts every value, ignoring duplicates.
Source§fn extend_one(&mut self, item: T)
fn extend_one(&mut self, item: T)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)Source§impl<T: Ord, const N: usize> FromIterator<T> for BLinkSet<T, N>
impl<T: Ord, const N: usize> FromIterator<T> for BLinkSet<T, N>
Source§fn from_iter<I: IntoIterator<Item = T>>(iterable: I) -> Self
fn from_iter<I: IntoIterator<Item = T>>(iterable: I) -> Self
Builds a set from an arbitrary value iterator.