Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
1 change: 0 additions & 1 deletion INVENTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.

Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
13 changes: 13 additions & 0 deletions examples/compact_vector.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
use jerky::int_vectors::CompactVectorBuilder;

fn main() -> Result<(), Box<dyn std::error::Error>> {
// 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(())
}