diff --git a/CHANGELOG.md b/CHANGELOG.md index ae4ac90..54111dc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -51,3 +51,4 @@ - Split inspection tests so each assertion stands alone. - Documented `WaveletMatrix` usage in `README.md`. - Moved README usage examples to runnable files in `examples/`. +- Added `compact_vector` example showing construction and retrieval. diff --git a/INVENTORY.md b/INVENTORY.md index b126805..854c345 100644 --- a/INVENTORY.md +++ b/INVENTORY.md @@ -5,7 +5,6 @@ ## Desired Functionality - Provide more usage examples and documentation. -- Add usage example demonstrating `CompactVector` construction and retrieval. - Evaluate additional succinct data structures to include. - Investigate alternative dense-select index strategies to replace removed `DArrayIndex`. diff --git a/README.md b/README.md index ed6b82b..123de91 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,8 @@ byte region to `Bytes::from_source`. ## Examples -See the [examples](examples/) directory for runnable usage demos. +See the [examples](examples/) directory for runnable usage demos, including +`bit_vector`, `wavelet_matrix`, and `compact_vector`. ## Licensing diff --git a/examples/compact_vector.rs b/examples/compact_vector.rs new file mode 100644 index 0000000..6134029 --- /dev/null +++ b/examples/compact_vector.rs @@ -0,0 +1,13 @@ +use jerky::int_vectors::CompactVectorBuilder; + +fn main() -> Result<(), Box> { + // Build a vector storing integers within 3 bits each. + let mut builder = CompactVectorBuilder::new(3)?; + builder.extend([7, 2, 5])?; + let cv = builder.freeze(); + + assert_eq!(cv.len(), 3); + assert_eq!(cv.get_int(0), Some(7)); + assert_eq!(cv.get_int(2), Some(5)); + Ok(()) +}