https://github.com/j-hc/mkbs-rs
Multi-Key Binary Search Implementation in Rust
https://github.com/j-hc/mkbs-rs
Last synced: 3 months ago
JSON representation
Multi-Key Binary Search Implementation in Rust
- Host: GitHub
- URL: https://github.com/j-hc/mkbs-rs
- Owner: j-hc
- License: apache-2.0
- Created: 2022-03-27T18:37:02.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2022-03-27T18:40:53.000Z (about 3 years ago)
- Last Synced: 2025-01-13T13:52:28.948Z (5 months ago)
- Language: Rust
- Size: 5.86 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# MKBS-rs
Multi-Key Binary Search Implementation in Rust
## Usage
```toml
# Cargo.toml
mkbs = { git = "https://github.com/j-hc/mkbs-rs" }
```Pseudo code:
```rustuse mkbs::MKBS;
let keys = &[123, 3131];
let vec_of_vals = (0..4123).collect::>();let results = vec_of_vals.mkbs(keys);
println!("{results:?}");
// [Ok(123), Ok(3131)]/// If the value is not found then [`Result::Err`] is returned, containing
/// the index where a matching element could be inserted while maintaining
/// sorted order, just like in the std library binary search.
/// In the case of [`MKBS::mkbs()`], it mostly returns [`Option::None`] in the place
/// of possible indices.
/// If you want every not-found element to have a possible index then you should
/// use [`MKBS::mkbs_all()`], note that it is almost two times slower.
```