Skip to main content

Crate nexus_collections

Crate nexus_collections 

Source
Expand description

High-performance collections with slab-backed storage.

Collections use thread-local slab allocators for O(1) insert/remove with stable handles and no allocation on the hot path.

§Collections

  • List — Doubly-linked list with RcSlot handles and external allocation
  • Heap — Pairing heap with RcSlot handles and external allocation
  • RbTree — Red-black tree sorted map with deterministic O(log n) worst case
  • BTree — B-tree sorted map with cache-friendly, tunable node layout

§Quick Start (RbTree)

mod levels {
    nexus_collections::rbtree_allocator!(u64, String, bounded);
}

fn main() {
    levels::Allocator::builder().capacity(1000).build().unwrap();

    let mut map = levels::RbTree::new(levels::Allocator);
    map.try_insert(100, "hello".into()).unwrap();
    assert_eq!(map.get(&100), Some(&"hello".into()));
}

Re-exports§

pub use compare::Compare;
pub use compare::Natural;
pub use compare::Reverse;
pub use exclusive::ExMut;
pub use exclusive::ExRef;
pub use exclusive::ExclusiveCell;

Modules§

btree
B-tree sorted map with internal slab allocation.
compare
Comparison strategy for tree key ordering.
exclusive
Single-borrow cell for exclusive access enforcement.
heap
Min-heap (pairing heap) with RcSlot-based stable handles.
list
Doubly-linked list with RcSlot-based ownership.
rbtree
Red-black tree sorted map with internal slab allocation.

Macros§

bounded_allocator
Generates a bounded (fixed-capacity) slab allocator for a type.
bounded_rc_allocator
Generates a bounded (fixed-capacity) reference-counted slab allocator.
btree_allocator
Creates a B-tree allocator for a specific key-value pair.
heap_allocator
Creates a heap allocator for a specific type.
list_allocator
Creates a list allocator for a specific type.
rbtree_allocator
Creates a red-black tree allocator for a specific key-value pair.
unbounded_allocator
Generates an unbounded (growable) slab allocator for a type.
unbounded_rc_allocator
Generates an unbounded (growable) reference-counted slab allocator.

Structs§

Full
Error returned when a bounded allocator is full.

Traits§

Alloc
Base trait for slab allocators - handles slot deallocation.
BoundedAlloc
Trait for bounded (fixed-capacity) allocators.
UnboundedAlloc
Trait for unbounded (growable) allocators.