Skip to main content

Crate logvec

Crate logvec 

Source
Expand description

logvec provides LogVec, a cache-friendly Bentley-Saxe logarithmic array.

It stores all elements in one contiguous Vec<T> and maintains sorted runs whose sizes follow the binary decomposition of len().

§Complexity

  • insert: amortized O(log n)
  • contains: O(log^2 n) (binary search across sorted runs)
  • delete: O(n) worst-case (removal + re-sort)

§Example

use logvec::LogVec;

let mut arr = LogVec::new();
arr.insert(5);
arr.insert(3);
arr.insert(8);

assert!(arr.contains(&5));
assert!(!arr.contains(&42));
assert_eq!(arr.delete(&3), Some(3));
assert!(!arr.contains(&3));

Structs§

LogVec
A Bentley-Saxe logarithmic array backed by a contiguous Vec<T>.