Struct rangemap::map::RangeMap

source ·
pub struct RangeMap<K, V> { /* private fields */ }
Expand description

A map whose keys are stored as (half-open) ranges bounded inclusively below and exclusively above (start..end).

Contiguous and overlapping ranges that map to the same value are coalesced into a single range.

Implementations§

Makes a new empty RangeMap.

Returns a reference to the value corresponding to the given key, if the key is covered by any range in the map.

Returns the range-value pair (as a pair of references) corresponding to the given key, if the key is covered by any range in the map.

Returns true if any range in the map covers the specified key.

Gets an iterator over all pairs of key range and value, ordered by key range.

The iterator element type is (&'a Range<K>, &'a V).

Clears the map, removing all elements.

Returns the number of elements in the map.

Returns true if the map contains no elements.

Insert a pair of key range and value into the map.

If the inserted range partially or completely overlaps any existing range in the map, then the existing range (or ranges) will be partially or completely replaced by the inserted range.

If the inserted range either overlaps or is immediately adjacent any existing range mapping to the same value, then the ranges will be coalesced into a single contiguous range.

Panics

Panics if range start >= end.

Removes a range from the map, if all or any of it was present.

If the range to be removed partially overlaps any ranges in the map, then those ranges will be contracted to no longer cover the removed range.

Panics

Panics if range start >= end.

Gets an iterator over all the maximally-sized ranges contained in outer_range that are not covered by any range stored in the map.

If the start and end of the outer range are the same and it does not overlap any stored range, then a single empty gap will be returned.

The iterator element type is Range<K>.

Gets an iterator over all the stored ranges that are either partially or completely overlapped by the given range.

Returns true if any range in the map completely or partially overlaps the given range.

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
Extends a collection with the contents of an iterator. Read more
🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Creates a value from an iterator. Read more
The type of the elements being iterated over.
Which kind of iterator are we turning this into?
Creates an iterator from a value. Read more
This method returns an Ordering between self and other. Read more
Compares and returns the maximum of two values. Read more
Compares and returns the minimum of two values. Read more
Restrict a value to a certain interval. Read more
This method tests for self and other values to be equal, and is used by ==.
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
This method returns an ordering between self and other values if one exists. Read more
This method tests less than (for self and other) and is used by the < operator. Read more
This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
This method tests greater than (for self and other) and is used by the > operator. Read more
This method tests greater than or equal to (for self and other) and is used by the >= operator. 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

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
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.