Struct re_int_histogram::tree::Int64Histogram
source · pub struct Int64Histogram {
root: Node,
}
Expand description
Fields§
§root: Node
Implementations§
source§impl Int64Histogram
impl Int64Histogram
sourcepub fn increment(&mut self, key: i64, inc: u32)
pub fn increment(&mut self, key: i64, inc: u32)
Increment the count for the given key.
Incrementing with one is similar to inserting the key in a multi-set.
sourcepub fn decrement(&mut self, key: i64, dec: u32) -> u32
pub fn decrement(&mut self, key: i64, dec: u32) -> u32
Decrement the count for the given key.
The decrement is saturating.
Returns how much was actually decremented (found). If the returned value is less than the given value, it means that the key was either no found, or had a lower count.
sourcepub fn remove(&mut self, range: impl RangeBounds<i64>) -> u64
pub fn remove(&mut self, range: impl RangeBounds<i64>) -> u64
Remove all data in the given range.
Returns how much count was removed.
Currently the implementation is optimized for the case of removing large continuous ranges. Removing many small, scattered ranges (e.g. individual elements) may cause performance problems! This can be remedied with some more code.
sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Is the total count zero?
Note that incrementing a key with zero is a no-op and will leave an empty histogram still empty.
sourcepub fn total_count(&self) -> u64
pub fn total_count(&self) -> u64
Total count of all the buckets.
NOTE: this is NOT the number of unique keys.
sourcepub fn range_count(&self, range: impl RangeBounds<i64>) -> u64
pub fn range_count(&self, range: impl RangeBounds<i64>) -> u64
What is the count of all the buckets in the given range?
sourcepub fn range(&self, range: impl RangeBounds<i64>, cutoff_size: u64) -> Iter<'_> ⓘ
pub fn range(&self, range: impl RangeBounds<i64>, cutoff_size: u64) -> Iter<'_> ⓘ
Iterate over a certain range, returning ranges that are at most cutoff_size
long.
To get all individual entries, use cutoff_size<=1
.
When cutoff_size > 1
you MAY get ranges which include keys that has no count.
However, the ends (min/max) of all returned ranges will be keys with a non-zero count.
In other words, gaps in the key-space smaller than cutoff_size
MAY be ignored by this iterator.
For example, inserting two elements at 10
and 15
and setting a cutoff_size=10
you may get a single range [10, 15]
with the total count.
You may also get two ranges of [10, 10]
and [15, 15]
.
A larger cutoff_size
will generally yield fewer ranges, and will be faster.
Trait Implementations§
source§impl Clone for Int64Histogram
impl Clone for Int64Histogram
source§fn clone(&self) -> Int64Histogram
fn clone(&self) -> Int64Histogram
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more