pub struct NonOverlappingIntervalTree<K, V> { /* private fields */ }
Expand description

An implementation of a non-overlapping interval tree.

Keys are ranges, Range, and values are stored for a given range. Ranges inside the tree map not overlap, and the insert function enforces this. Internally managed by a BTreeMap.

Implementations

Construct a new non-overlapping interval tree.

Insert a value into the tree for a given range, not checking to see if any overlapping occurs. If there’s an element whose range starts with int’s start, that element is removed and returned.

Safety

This function can potentially corrupt the tree, since the normal operation functions rely on there being no overlaps. Care must be taken when using this function to ensure the no-overlap property manually.

Insert a value into the tree for a given range, removing and returning all K,V pairs that are in the tree that overlap with the inserted range.

Examples
use nonoverlapping_interval_tree::NonOverlappingIntervalTree;
let mut it = NonOverlappingIntervalTree::new();
it.insert_replace(1..3, "hello");

Get an immutable reference to the value of a single point in the interval tree, returning the value for a range that contains this point if one exists.

Get a mutable reference to the value of a single point in the interval tree, returning the value for a range that contains this point if one exists.

Remove the value associated with the range that contains the point argument. If one is present, it is removed and returned, otherwise None is returned.

Returns a double-ended iterator over a sub-range of elements in the map. The resulting range may contain individual points that are not in the provided range if the stored ranges overlap with the terminating point. For example, if the tree contains [[1..3], [4..6]], and you call tree.range(1..5), you’ll get back [[1..3], [4..6]], since the 4..6 range contains 4 as requested by the call to range.

Returns a mutable double-ended iterator over a sub-range of elements in the map. The resulting range may contain individual points that are not in the provided range if the stored ranges overlap with the terminating point. For example, if the tree contains [[1..3], [4..6]], and you call tree.range(1..5), you’ll get back [[1..3], [4..6]], since the 4..6 range contains 4 as requested by the call to range.

Remove all elements in the tree.

Return an iterator for the tree, sorted by key.

Return an iterator for the tree, sorted by key.

Returns the number of elements in the map.

Returns true if the map contains no elements.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.