pub struct PositionSet { /* private fields */ }Expand description
A set of usize positions stored as a BitSet. Provides O(1) membership testing and efficient set operations. Caches bounds for cheap overlap pre-checks.
Implementations§
Source§impl PositionSet
impl PositionSet
Sourcepub fn from_usize_iter<I: IntoIterator<Item = usize>>(iter: I) -> Self
pub fn from_usize_iter<I: IntoIterator<Item = usize>>(iter: I) -> Self
Create a PositionSet from an iterator of usize positions.
Sourcepub fn min_pos(&self) -> usize
pub fn min_pos(&self) -> usize
Returns the minimum position in the set.
Returns usize::MAX for an empty set.
Sourcepub fn max_pos(&self) -> usize
pub fn max_pos(&self) -> usize
Returns the maximum position in the set.
Returns 0 for an empty set.
Sourcepub fn extend_from_span(&mut self, span: &PositionSpan)
pub fn extend_from_span(&mut self, span: &PositionSpan)
Extend this set from a PositionSpan without allocating an intermediate set.
Sourcepub fn remove_span(&mut self, span: &PositionSpan)
pub fn remove_span(&mut self, span: &PositionSpan)
Remove all positions in a span from the set.
Sourcepub fn may_overlap_range(&self, range_start: usize, range_end: usize) -> bool
pub fn may_overlap_range(&self, range_start: usize, range_end: usize) -> bool
Quick check if a range [range_start, range_end) might overlap with this set. Returns true if the bounding boxes overlap, false if they definitely don’t. This is O(1) and used as a pre-filter before the expensive BitSet check.
Sourcepub fn union(&self, other: &PositionSet) -> PositionSet
pub fn union(&self, other: &PositionSet) -> PositionSet
Compute the union of this set with another PositionSet.
Returns a new PositionSet containing all positions from both sets.
Sourcepub fn difference(&self, other: &PositionSet) -> PositionSet
pub fn difference(&self, other: &PositionSet) -> PositionSet
Return the difference (elements in self but not in other).
Sourcepub fn intersection_len(&self, other: &PositionSet) -> usize
pub fn intersection_len(&self, other: &PositionSet) -> usize
Count elements in the intersection of self and other.
Sourcepub fn overlaps_span(&self, span: &PositionSpan) -> bool
pub fn overlaps_span(&self, span: &PositionSpan) -> bool
Check if this set overlaps with a PositionSpan. Uses O(1) bounds check before the O(n) element-wise check.
Sourcepub fn contains_range(&self, range: Range<usize>) -> bool
pub fn contains_range(&self, range: Range<usize>) -> bool
Check if this set contains all positions in a range. Returns true for empty ranges.
Sourcepub fn to_position_span(&self) -> PositionSpan
pub fn to_position_span(&self) -> PositionSpan
Convert this PositionSet to a PositionSpan.
If positions are contiguous, returns a Range; otherwise returns Discrete.
Trait Implementations§
Source§impl Clone for PositionSet
impl Clone for PositionSet
Source§fn clone(&self) -> PositionSet
fn clone(&self) -> PositionSet
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PositionSet
impl Debug for PositionSet
Source§impl Default for PositionSet
impl Default for PositionSet
Source§impl FromIterator<usize> for PositionSet
impl FromIterator<usize> for PositionSet
Source§impl PartialEq for PositionSet
impl PartialEq for PositionSet
impl Eq for PositionSet
impl StructuralPartialEq for PositionSet
Auto Trait Implementations§
impl Freeze for PositionSet
impl RefUnwindSafe for PositionSet
impl Send for PositionSet
impl Sync for PositionSet
impl Unpin for PositionSet
impl UnsafeUnpin for PositionSet
impl UnwindSafe for PositionSet
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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 moreSource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<U, T> ToOwnedObj<U> for Twhere
U: FromObjRef<T>,
impl<U, T> ToOwnedObj<U> for Twhere
U: FromObjRef<T>,
Source§fn to_owned_obj(&self, data: FontData<'_>) -> U
fn to_owned_obj(&self, data: FontData<'_>) -> U
T, using the provided data to resolve any offsets.