Skip to main content

embed_seglist/
lib.rs

1#![allow(rustdoc::redundant_explicit_links)]
2#![cfg_attr(docsrs, feature(doc_cfg))]
3#![cfg_attr(docsrs, allow(unused_attributes))]
4
5//! # SegList
6//!
7//! [SegList](crate::seglist) is a replacement for linked list, and Vec (when you don't need random
8//! access)
9//!
10//! [Various](crate::various) is designed for parameter passing, which wraps `Option` & `SegList`, when the optimal condition is empty or one.
11//!
12//! More CPU-cache friendly compared to `LinkedList`. And because it does not re-allocate, it's faster than `Vec::push()` when the number of elements is small.
13//! It's nice to the memory allocator (always allocate with fixed size segment).
14//!
15//! Benchmark: append + drain (x86_64, cache line 128 bytes):
16//!
17//! (platform: intel i7-8550U)
18//!
19//! | Elements | SegList | Vec | SegList vs Vec |
20//! |----------|---------|-----|----------------|
21//! | 10 | 40.5 ns | 147.0 ns | **3.6x faster** |
22//! | 32 | 99.1 ns | 237.8 ns | **2.4x faster** |
23//! | 100 | 471.1 ns | 464.0 ns | ~1.0x |
24//! | 500 | 2.77 µs | 895.5 ns | 3.1x slower |
25
26extern crate alloc;
27
28pub mod various;
29pub use various::Various;
30pub mod seglist;
31pub use seglist::SegList;