A data structure to find smallest key that is larger than the query.
Suppose we have a following weight dependent price table.
weight,price
100,10
200,15
500,30
The price is decided by the smallest entry whose weight
key is greater than the query.
examples
sh
cargo add threshold_dict
A ThresholdDict
can be created by passing kv pairs. If query is greater than or equal to all of the keys, None is returned.
```rust let kvpairs = vec![(100, 10), (200, 15), (500, 30)]; let dict = ThresholdDict::from(kvpairs);
asserteq!(dict.query(&90), Some(&10)); asserteq!(dict.query(600), None); ```