Struct regex_syntax::hir::interval::IntervalSet
source · pub struct IntervalSet<I> {
ranges: Vec<I>,
folded: bool,
}
Fields§
§ranges: Vec<I>
A sorted set of non-overlapping ranges.
folded: bool
While not required at all for correctness, we keep track of whether an interval set has been case folded or not. This helps us avoid doing redundant work if, for example, a set has already been cased folded. And note that whether a set is folded or not is preserved through all of the pairwise set operations. That is, if both interval sets have been case folded, then any of difference, union, intersection or symmetric difference all produce a case folded set.
Note that when this is true, it must be the case that the set is case folded. But when it’s false, the set may be case folded. In other words, we only set this to true when we know it to be case, but we’re okay with it being false if it would otherwise be costly to determine whether it should be true. This means code cannot assume that a false value necessarily indicates that the set is not case folded.
Bottom line: this is a performance optimization.
Implementations§
source§impl<I: Interval> IntervalSet<I>
impl<I: Interval> IntervalSet<I>
sourcepub fn new<T: IntoIterator<Item = I>>(intervals: T) -> IntervalSet<I>
pub fn new<T: IntoIterator<Item = I>>(intervals: T) -> IntervalSet<I>
Create a new set from a sequence of intervals. Each interval is specified as a pair of bounds, where both bounds are inclusive.
The given ranges do not need to be in any specific order, and ranges may overlap.
sourcepub fn iter(&self) -> IntervalSetIter<'_, I> ⓘ
pub fn iter(&self) -> IntervalSetIter<'_, I> ⓘ
Return an iterator over all intervals in this set.
The iterator yields intervals in ascending order.
sourcepub fn intervals(&self) -> &[I]
pub fn intervals(&self) -> &[I]
Return an immutable slice of intervals in this set.
The sequence returned is in canonical ordering.
sourcepub fn case_fold_simple(&mut self) -> Result<(), CaseFoldError>
pub fn case_fold_simple(&mut self) -> Result<(), CaseFoldError>
Expand this interval set such that it contains all case folded
characters. For example, if this class consists of the range a-z
,
then applying case folding will result in the class containing both the
ranges a-z
and A-Z
.
This returns an error if the necessary case mapping data is not available.
sourcepub fn union(&mut self, other: &IntervalSet<I>)
pub fn union(&mut self, other: &IntervalSet<I>)
Union this set with the given set, in place.
sourcepub fn intersect(&mut self, other: &IntervalSet<I>)
pub fn intersect(&mut self, other: &IntervalSet<I>)
Intersect this set with the given set, in place.
sourcepub fn difference(&mut self, other: &IntervalSet<I>)
pub fn difference(&mut self, other: &IntervalSet<I>)
Subtract the given set from this set, in place.
sourcepub fn symmetric_difference(&mut self, other: &IntervalSet<I>)
pub fn symmetric_difference(&mut self, other: &IntervalSet<I>)
Compute the symmetric difference of the two sets, in place.
This computes the symmetric difference of two interval sets. This removes all elements in this set that are also in the given set, but also adds all elements from the given set that aren’t in this set. That is, the set will contain all elements in either set, but will not contain any elements that are in both sets.
sourcepub fn negate(&mut self)
pub fn negate(&mut self)
Negate this interval set.
For all x
where x
is any element, if x
was in this set, then it
will not be in this set after negation.
sourcefn canonicalize(&mut self)
fn canonicalize(&mut self)
Converts this set into a canonical ordering.
sourcefn is_canonical(&self) -> bool
fn is_canonical(&self) -> bool
Returns true if and only if this class is in a canonical ordering.
Trait Implementations§
source§impl<I: Clone> Clone for IntervalSet<I>
impl<I: Clone> Clone for IntervalSet<I>
source§fn clone(&self) -> IntervalSet<I>
fn clone(&self) -> IntervalSet<I>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<I: Debug> Debug for IntervalSet<I>
impl<I: Debug> Debug for IntervalSet<I>
source§impl<I: Interval> PartialEq for IntervalSet<I>
impl<I: Interval> PartialEq for IntervalSet<I>
impl<I: Interval> Eq for IntervalSet<I>
Auto Trait Implementations§
impl<I> Freeze for IntervalSet<I>
impl<I> RefUnwindSafe for IntervalSet<I>where
I: RefUnwindSafe,
impl<I> Send for IntervalSet<I>where
I: Send,
impl<I> Sync for IntervalSet<I>where
I: Sync,
impl<I> Unpin for IntervalSet<I>where
I: Unpin,
impl<I> UnwindSafe for IntervalSet<I>where
I: 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
)