Skip to main content

Crate paged_collections

Crate paged_collections 

Source
Expand description

Paged collections: containers whose memory is split into fixed-size pages.

Paging serves two separate purposes, and each collection states which it uses:

  • Paged index. A lookup table indexed by key is split into pages that are allocated on first use, so memory follows the occupied key ranges rather than the largest key ever inserted.
  • Paged storage. Elements live in fixed-size pages that never move, so references and pointers to elements stay valid while the collection grows.

§Collections

ModuleTypePaging
sparse_setPagedSparseSet<K>index; storage optional
sparse_mapPagedSparseMap<K, V>index; storage optional
priority_queuePagedPriorityQueue<K, P>index (indexed max-heap)
direct_mapPagedDirectMap<K, V>index (values in place, slot order)
bit_setPagedBitSet<K>index (1 bit per slot)
paged_vecPagedVec<T>storage (stable addresses)
paged_dequePagedDeque<T>storage (stable addresses, double-ended)
hiveHive<T>storage (stable addresses, reusable slots, generational ids)
id_allocIdAllocator, Idnone (free list of generational ids)

Shared building blocks live in key (how a key maps to an index) and page (the page directory).

§Features

  • std (default): std-only conveniences. Without it the crate is no_std and needs only alloc.
  • serde: serialization support.
  • rayon: parallel iteration through rayon::prelude. Enables std.
  • concurrent: thread-safe variants in concurrent, which use unsafe code and atomics. Includes an MPMC FIFO ConcurrentQueue that waits at page boundaries and a sharded ConcurrentPriorityQueue with relaxed pop and exact pop_exact. Off by default.

Modules§

bit_set
PagedBitSet: a set that stores one bit per key slot in fixed-size pages.
concurrentconcurrent
Concurrent containers using the same generational ids as the plain types.
direct_map
PagedDirectMap: a direct-address map whose values live in place in a paged index.
hive32-bit or 64-bit
Hive: an unordered container with stable addresses, reusable slots and generational handles.
id_alloc32-bit or 64-bit
IdAllocator: hands out generational Ids and recycles freed ones.
key
Keys and how they map to slot indices.
page
Page directories: where the pages of a paged index live.
paged_deque
PagedDeque: a double-ended queue stored in fixed-size pages.
paged_vec
PagedVec: a growable vector stored in fixed-size pages.
priority_queue
PagedPriorityQueue: an indexed max-heap with a paged key index.
sparse_map
PagedSparseMap: a paged sparse set that stores one value per key.
sparse_set
PagedSparseSet: a sparse set whose sparse index is paged.