pub struct SpanMap<K, V>{ /* private fields */ }Expand description
A map that associates spans (ranges) with sets of values.
SpanMap maintains a mapping between spans and sets of values, where:
- Each span represents a continuous range with well-defined boundaries
- Multiple values can be associated with the same span
- Spans can overlap, resulting in points that contain multiple values
- Queries at any point return all values associated with spans containing that point
The implementation uses a B-tree based data structure for efficient operations.
§Type Parameters
K: The type of the keys defining span boundaries. Must implementCloneandOrd.V: The type of values stored in the sets. Must implementCloneandOrd.
Implementations§
Source§impl<K, V> SpanMap<K, V>
impl<K, V> SpanMap<K, V>
Sourcepub fn get(&self, key: &K) -> impl Iterator<Item = &V>
pub fn get(&self, key: &K) -> impl Iterator<Item = &V>
Returns an iterator over all values associated with spans containing the given key.
Sourcepub fn insert<R>(&mut self, range: R, value: V)where
R: RangeBounds<K>,
pub fn insert<R>(&mut self, range: R, value: V)where
R: RangeBounds<K>,
Inserts a value into all sets associated with spans overlapping the given range.
Adjacent ranges with the same value are merged into a single range.
Sourcepub fn remove<R>(&mut self, range: R, value: V)where
R: RangeBounds<K>,
pub fn remove<R>(&mut self, range: R, value: V)where
R: RangeBounds<K>,
Removes a value from all sets associated with spans overlapping the given range.
Adjacent ranges with the same value are merged into a single range.
Trait Implementations§
impl<K, V> Eq for SpanMap<K, V>
impl<K, V> StructuralPartialEq for SpanMap<K, V>
Auto Trait Implementations§
impl<K, V> Freeze for SpanMap<K, V>
impl<K, V> RefUnwindSafe for SpanMap<K, V>where
K: RefUnwindSafe,
V: RefUnwindSafe,
impl<K, V> Send for SpanMap<K, V>
impl<K, V> Sync for SpanMap<K, V>
impl<K, V> Unpin for SpanMap<K, V>
impl<K, V> UnwindSafe for SpanMap<K, V>where
K: RefUnwindSafe,
V: RefUnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more