Elias-Fano Encoding in Rust
A Rust implementation of the Elias-Fano encoding scheme for storing monotonic sequences of integers efficiently.
Features
- Efficient storage of monotonic sequences
- O(1) access to elements
- Support for duplicate values
- Builder pattern for incremental construction
- Iterator support
- Serialization/deserialization support via serde
- No unsafe code
Usage
Add this to your Cargo.toml:
[]
= "0.1.0"
Basic example:
use EliasFano;
// Create from a sorted sequence
let values = vec!;
let seq = from;
// Access elements
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
// Iterate over values
let collected: = seq.iter.collect;
assert_eq!;
Using the builder pattern:
use EliasFanoBuilder;
let mut builder = new; // universe=10, count=4
builder.add;
builder.add;
builder.add;
builder.add;
let seq = builder.finalize;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
Performance
The structure provides O(1) access to elements while using approximately 2n + log(u/n) bits of space, where n is the number of elements and u is the universe size (maximum value + 1).
Documentation
For detailed documentation, visit docs.rs.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.