An open API service indexing awesome lists of open source software.

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

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:
```rust

use 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.
```