struct DenseRangeMapBuilder<K, V1, V2> {
starts: Vec<K>,
values1: Vec<Option<V1>>,
values2: Option<Vec<Option<V2>>>,
prev_end: Option<K>,
}Expand description
A helper type to create a DenseRangeMap from a sorted list of disjoint ranges.
§Invariants
starts.len() == values.len()startsis sorted and contains no duplicates.startsis empty if and only ifprev_endis None.
§Semantics
If starts is empty, nothing has been added to this Builder.
Otherwise:
- Every key such that
K::min <= key < starts[0]maps to None. - Every key such that
starts[idx] <= key < starts[idx+1]maps tovalues[idx], which may be Some or None. - Every key such that
key <= starts.last() <= prev_endmaps tovalues.last(). - No mappings have been added for any range S..=E such that ’S > prev_end`.
Fields§
§starts: Vec<K>A list of range starts so far.
values1: Vec<Option<V1>>A list of values so far.
values2: Option<Vec<Option<V2>>>A list of secondary values so far.
None if we’re ignoring secondary values.
prev_end: Option<K>The last element of the most recently added range.
Implementations§
Source§impl<K, V1, V2> DenseRangeMapBuilder<K, V1, V2>
impl<K, V1, V2> DenseRangeMapBuilder<K, V1, V2>
Sourcefn push(&mut self, start: K, v1: Option<V1>, v2: Option<V2>)
fn push(&mut self, start: K, v1: Option<V1>, v2: Option<V2>)
Add a single entry to this builder.
Sourcefn build(self) -> DenseRangeMap<K, V1, V2>
fn build(self) -> DenseRangeMap<K, V1, V2>
Consume this builder and return a DenseRangeMap with the same values.
Sourcefn add_entry(
&mut self,
range: RangeInclusive<K>,
value1: Option<V1>,
value2: Option<V2>,
) -> Result<(), Error>
fn add_entry( &mut self, range: RangeInclusive<K>, value1: Option<V1>, value2: Option<V2>, ) -> Result<(), Error>
Add an entry to this DenseRangeMapBuilder.
Returns an error if range is not in strictly ascending order with respect
to all previous ranges.
Auto Trait Implementations§
impl<K, V1, V2> Freeze for DenseRangeMapBuilder<K, V1, V2>where
K: Freeze,
impl<K, V1, V2> RefUnwindSafe for DenseRangeMapBuilder<K, V1, V2>
impl<K, V1, V2> Send for DenseRangeMapBuilder<K, V1, V2>
impl<K, V1, V2> Sync for DenseRangeMapBuilder<K, V1, V2>
impl<K, V1, V2> Unpin for DenseRangeMapBuilder<K, V1, V2>
impl<K, V1, V2> UnsafeUnpin for DenseRangeMapBuilder<K, V1, V2>where
K: UnsafeUnpin,
impl<K, V1, V2> UnwindSafe for DenseRangeMapBuilder<K, V1, V2>
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