Skip to main content

BLinkSet

Struct BLinkSet 

Source
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>

Source

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?
examples/basic.rs (line 7)
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

pub fn len(&self) -> usize

Returns the number of values observed by the set’s atomic counter.

Source

pub fn is_empty(&self) -> bool

Returns true when the set is empty at the instant it is observed.

Source

pub fn clear(&mut self)

Removes every value and restores one empty root leaf.

Source§

impl<T: Ord, const N: usize> BLinkSet<T, N>

Source

pub fn contains<Q>(&self, value: &Q) -> bool
where T: Borrow<Q>, Q: Ord + ?Sized,

Returns true when an ordering-compatible borrowed value is present.

Examples found in repository?
examples/basic.rs (line 15)
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

pub fn get<Q>(&self, value: &Q) -> Option<SetRef<'_, T, N>>
where T: Borrow<Q>, Q: Ord + ?Sized,

Returns a guard for the stored value equal to value.

Source

pub fn insert(&self, value: T) -> bool

Inserts value, returning true only when it was not already present.

Examples found in repository?
examples/basic.rs (line 8)
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

pub fn remove<Q>(&self, value: &Q) -> bool
where T: Borrow<Q>, Q: Ord + ?Sized,

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.

Source

pub fn first(&self) -> Option<SetRef<'_, T, N>>

Returns a guard for the least value.

Source

pub fn last(&self) -> Option<SetRef<'_, T, N>>

Returns a guard for the greatest value.

Source

pub fn iter(&self) -> SetIter<'_, T, N> ⓘ

Returns a weakly consistent ascending iterator over guarded values.

Source

pub fn range<Q, R>(&self, bounds: R) -> SetRange<'_, T, Q, R, N> ⓘ
where T: Borrow<Q>, Q: Ord + ?Sized, R: RangeBounds<Q>,

Returns a weakly consistent ascending iterator over bounds.

§Panics

Panics for an inverted range or equal bounds that are both excluded.

Source

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.

Source

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.

Source

pub fn is_superset(&self, other: &Self) -> bool

Returns true when every observed value in other is in this set.

Trait Implementations§

Source§

impl<T: Ord + Debug, const N: usize> Debug for BLinkSet<T, N>

Source§

fn fmt(&self, formatter: &mut Formatter<'_>) -> Result

Formats a weakly consistent ascending view of the set.

Source§

impl<T, const N: usize> Default for BLinkSet<T, N>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<T: Ord, const N: usize> Eq for BLinkSet<T, N>

Source§

impl<T: Ord, const N: usize> Extend<T> for BLinkSet<T, N>

Source§

fn extend<I: IntoIterator<Item = T>>(&mut self, iterable: I)

Inserts every value, ignoring duplicates.

Source§

fn extend_one(&mut self, item: T)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Source§

impl<T: Ord, const N: usize> FromIterator<T> for BLinkSet<T, N>

Source§

fn from_iter<I: IntoIterator<Item = T>>(iterable: I) -> Self

Builds a set from an arbitrary value iterator.

Source§

impl<'set, T: Ord, const N: usize> IntoIterator for &'set BLinkSet<T, N>

Source§

fn into_iter(self) -> Self::IntoIter

Creates the same guarded iterator as BLinkSet::iter.

Source§

type Item = SetRef<'set, T, N>

The type of the elements being iterated over.
Source§

type IntoIter = SetIter<'set, T, N>

Which kind of iterator are we turning this into?
Source§

impl<T: Ord, const N: usize> PartialEq for BLinkSet<T, N>

Source§

fn eq(&self, other: &Self) -> bool

Compares weakly consistent ordered views of both sets.

1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more

Auto Trait Implementations§

§

impl<T, const N: usize = DEFAULT_PAGE_CAPACITY> !Freeze for BLinkSet<T, N>

§

impl<T, const N: usize = DEFAULT_PAGE_CAPACITY> !RefUnwindSafe for BLinkSet<T, N>

§

impl<T, const N: usize = DEFAULT_PAGE_CAPACITY> !UnwindSafe for BLinkSet<T, N>

§

impl<T, const N: usize> Send for BLinkSet<T, N>
where BLinkMap<T, (), N>: Send,

§

impl<T, const N: usize> Sync for BLinkSet<T, N>
where BLinkMap<T, (), N>: Sync,

§

impl<T, const N: usize> Unpin for BLinkSet<T, N>
where BLinkMap<T, (), N>: Unpin,

§

impl<T, const N: usize> UnsafeUnpin for BLinkSet<T, N>
where BLinkMap<T, (), N>: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.