Struct shadow_rs::utility::interval_map::IntervalMap
source · pub struct IntervalMap<V> { /* private fields */ }
Implementations§
source§impl<V: Clone> IntervalMap<V>
impl<V: Clone> IntervalMap<V>
Maps from non-overlapping Interval
s to V
.
pub fn new() -> IntervalMap<V>
sourcepub fn keys(&self) -> KeyIter<'_, V> ⓘ
pub fn keys(&self) -> KeyIter<'_, V> ⓘ
Returns iterator over all intervals keys, in sorted order.
sourcepub fn iter(&self) -> ItemIter<'_, V> ⓘ
pub fn iter(&self) -> ItemIter<'_, V> ⓘ
Returns iterator over all intervals keys and their values, in order by interval key.
sourcepub fn iter_from(&self, begin: usize) -> ItemIter<'_, V> ⓘ
pub fn iter_from(&self, begin: usize) -> ItemIter<'_, V> ⓘ
Returns iterator over all interval keys and their values, starting with the first interval
containing or after begin
.
sourcepub fn clear(&mut self, interval: Interval) -> Vec<Mutation<V>>
pub fn clear(&mut self, interval: Interval) -> Vec<Mutation<V>>
Mutates the map so that the given range maps to nothing, modifying and removing intervals as needed. Returns what mutations were performed, including the values of any completely-removed intervals. If an interval is split (e.g. by inserting [5,6] into [0,10]), its value will be cloned.
Returned mutations are ordered by their original interval values.
sourcepub fn insert(&mut self, interval: Interval, val: V) -> Vec<Mutation<V>>
pub fn insert(&mut self, interval: Interval, val: V) -> Vec<Mutation<V>>
Insert range from start
to end
, inclusive, mapping that range to val
. Existing
contents of that range are cleared, and mutations returned, as for clear
.
pub fn get(&self, x: usize) -> Option<(Interval, &V)>
pub fn get_mut(&mut self, x: usize) -> Option<(Interval, &mut V)>
Trait Implementations§
source§impl<V: Clone> Clone for IntervalMap<V>
impl<V: Clone> Clone for IntervalMap<V>
source§fn clone(&self) -> IntervalMap<V>
fn clone(&self) -> IntervalMap<V>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<V: Debug> Debug for IntervalMap<V>
impl<V: Debug> Debug for IntervalMap<V>
Auto Trait Implementations§
impl<V> Freeze for IntervalMap<V>
impl<V> RefUnwindSafe for IntervalMap<V>where
V: RefUnwindSafe,
impl<V> Send for IntervalMap<V>where
V: Send,
impl<V> Sync for IntervalMap<V>where
V: Sync,
impl<V> Unpin for IntervalMap<V>where
V: Unpin,
impl<V> UnwindSafe for IntervalMap<V>where
V: UnwindSafe,
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more