cuml_map/cmap.rs
1/// Trait for building and querying mappings between keys and cumulative
2/// values.
3pub trait CumlMap {
4 /// Type for the keys in this mapping.
5 type Key;
6
7 /// Type for the values in this mapping.
8 type Value;
9
10 /// Insert an entry into the mapping.
11 fn insert(&mut self, Self::Key, Self::Value);
12
13 /// Get the cumulative value up to and including
14 /// the specified key.
15 fn get_cuml(&self, Self::Key) -> Self::Value;
16
17 /// Get the value at the specified key (not the cumulative value).
18 fn get_single(&self, Self::Key) -> Self::Value;
19
20 /// Get the first key at which the cumulative value equals or exceeds
21 /// the specified value, if such a key exists.
22 /// Note that if the result of this function is only defined if the
23 /// cumulative value is non-decreasing. If you start putting negative
24 /// values into your mappings, you will get strange results from this
25 /// function.
26 fn get_quantile(&self, Self::Value) -> Option<Self::Key>;
27}