Trait OrdUpperBound

Source
pub trait OrdUpperBound {
    // Required method
    fn cmp_upper_bound(&self, other: &Self) -> Ordering;
}
Expand description

The find functions will return items with keys that are greater-than or equal to the search key, so for keys that are like extents, the keys should sort (via OrdUpperBound) using the end of their ranges, and you should set the search key accordingly.

For example, let’s say the tree holds extents 100..200, 200..250 and you want to perform a read for range 150..250, you should search for 0..151 which will first return the extent 100..200 (and then the iterator can be advanced to 200..250 after). When merging, keys can overlap, so consider the case where we want to merge an extent with range 100..300 with an existing extent of 200..250. In that case, we want to treat the extent with range 100..300 as lower than the key 200..250 because we’ll likely want to split the extents (e.g. perhaps we want 100..200, 200..250, 250..300), so for merging, we need to use a different comparison function and we deal with that using the OrdLowerBound trait.

If your keys don’t have overlapping ranges that need to be merged, then these can be the same as std::cmp::Ord (use the DefaultOrdUpperBound and DefaultOrdLowerBound traits).

Required Methods§

Source

fn cmp_upper_bound(&self, other: &Self) -> Ordering

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§