Skip to main content

b_link/
lib.rs

1//! Concurrent ordered map and set collections implemented as a B-link tree.
2//!
3//! [`BLinkMap`] and [`BLinkSet`] use per-page read/write latches, two-sided
4//! fences, right-sibling links, and forwarding pages. Readers correct stale
5//! routes while concurrent writers split, rotate, merge, and unlink pages.
6//!
7//! Entry lookups return [`EntryRef`] or [`EntryMut`] guards. These guards make
8//! borrowed access safe without cloning values, but they lock an entire leaf.
9//! Drop them before re-entering the map for a potentially conflicting operation.
10//!
11//! ```
12//! use b_link::{BLinkMap, BLinkSet};
13//!
14//! let map = BLinkMap::<u64, &str>::new();
15//! assert_eq!(map.insert(7, "seven"), None);
16//! assert_eq!(map.get(&7).map(|entry| *entry), Some("seven"));
17//! assert_eq!(map.remove(&7), Some("seven"));
18//!
19//! let set = BLinkSet::<u64>::new();
20//! assert!(set.insert(7));
21//! assert!(set.contains(&7));
22//! ```
23
24#![warn(missing_docs)]
25#![forbid(unsafe_op_in_unsafe_fn)]
26
27mod array;
28mod handle;
29mod iter;
30mod map;
31mod node;
32mod set;
33
34pub use handle::{EntryMut, EntryRef};
35pub use iter::{Iter, KeyRef, Keys, Range, ValueRef, Values};
36pub use map::{BLinkMap, DEFAULT_PAGE_CAPACITY};
37pub use set::{BLinkSet, SetIter, SetRange, SetRef};