Struct read_fonts::collections::int_set::IntSet
source · pub struct IntSet<T>(/* private fields */);
Expand description
A fast & efficient invertible ordered set for small (up to 32-bit) unsigned integer types.
Implementations§
source§impl IntSet<u32>
impl IntSet<u32>
sourcepub fn from_sparse_bit_set(data: &[u8]) -> Result<IntSet<u32>, DecodingError>
pub fn from_sparse_bit_set(data: &[u8]) -> Result<IntSet<u32>, DecodingError>
Populate this set with the values obtained from decoding the provided sparse bit set bytes.
Sparse bit sets are a specialized, compact encoding of bit sets defined in the IFT specification: https://w3c.github.io/IFT/Overview.html#sparse-bit-set-decoding
sourcepub fn from_sparse_bit_set_bounded(
data: &[u8],
bias: u32,
max_value: u32,
) -> Result<(IntSet<u32>, &[u8]), DecodingError>
pub fn from_sparse_bit_set_bounded( data: &[u8], bias: u32, max_value: u32, ) -> Result<(IntSet<u32>, &[u8]), DecodingError>
Populate this set with the values obtained from decoding the provided sparse bit set bytes.
During decoding bias will be added to each decoded set members value. The final set will not contain any values larger than max_value: any encoded values larger than max_value after the bias is applied are ignored.
Sparse bit sets are a specialized, compact encoding of bit sets defined in the IFT specification: https://w3c.github.io/IFT/Overview.html#sparse-bit-set-decoding
sourcepub fn to_sparse_bit_set(&self) -> Vec<u8>
pub fn to_sparse_bit_set(&self) -> Vec<u8>
Encode this set as a sparse bit set byte encoding.
Sparse bit sets are a specialized, compact encoding of bit sets defined in the IFT specification: https://w3c.github.io/IFT/Overview.html#sparse-bit-set-decoding
source§impl<T: Domain> IntSet<T>
impl<T: Domain> IntSet<T>
sourcepub fn iter(&self) -> impl DoubleEndedIterator<Item = T> + '_
pub fn iter(&self) -> impl DoubleEndedIterator<Item = T> + '_
Returns an iterator over all members of the set in sorted ascending order.
Note: iteration of inverted sets can be extremely slow due to the very large number of members in the set
care should be taken when using .iter()
in combination with an inverted set.
sourcepub fn inclusive_iter(&self) -> Option<impl DoubleEndedIterator<Item = T> + '_>
pub fn inclusive_iter(&self) -> Option<impl DoubleEndedIterator<Item = T> + '_>
If this is an inclusive membership set then returns an iterator over the members, otherwise returns None
.
sourcepub fn iter_after(&self, value: T) -> impl Iterator<Item = T> + '_
pub fn iter_after(&self, value: T) -> impl Iterator<Item = T> + '_
Returns an iterator over the members of this set that come after value
in ascending order.
Note: iteration of inverted sets can be extremely slow due to the very large number of members in the set
care should be taken when using .iter()
in combination with an inverted set.
sourcepub fn iter_ranges(&self) -> impl Iterator<Item = RangeInclusive<T>> + '_
pub fn iter_ranges(&self) -> impl Iterator<Item = RangeInclusive<T>> + '_
Returns an iterator over all disjoint ranges of values within the set in sorted ascending order.
sourcepub fn insert(&mut self, val: T) -> bool
pub fn insert(&mut self, val: T) -> bool
Adds a value to the set.
Returns true
if the value was newly inserted.
sourcepub fn insert_range(&mut self, range: RangeInclusive<T>)
pub fn insert_range(&mut self, range: RangeInclusive<T>)
Add all values in range as members of this set.
sourcepub fn extend_unsorted<U: IntoIterator<Item = T>>(&mut self, iter: U)
pub fn extend_unsorted<U: IntoIterator<Item = T>>(&mut self, iter: U)
An alternate version of extend()
which is optimized for inserting an unsorted iterator of values.
sourcepub fn remove(&mut self, val: T) -> bool
pub fn remove(&mut self, val: T) -> bool
Removes a value from the set. Returns whether the value was present in the set.
pub fn remove_all<U: IntoIterator<Item = T>>(&mut self, iter: U)
sourcepub fn remove_range(&mut self, range: RangeInclusive<T>)
pub fn remove_range(&mut self, range: RangeInclusive<T>)
Removes all values in range as members of this set.
sourcepub fn union(&mut self, other: &IntSet<T>)
pub fn union(&mut self, other: &IntSet<T>)
Sets the members of this set to the union of self and other.
sourcepub fn intersect(&mut self, other: &IntSet<T>)
pub fn intersect(&mut self, other: &IntSet<T>)
Sets the members of this set to the intersection of self and other.
sourcepub fn intersects_range(&self, range: RangeInclusive<T>) -> bool
pub fn intersects_range(&self, range: RangeInclusive<T>) -> bool
Returns true if this set contains at least one element in ‘range’.
sourcepub fn intersects_set(&self, other: &IntSet<T>) -> bool
pub fn intersects_set(&self, other: &IntSet<T>) -> bool
Returns true if this set contains at least one element in ‘other’.
sourcepub fn first(&self) -> Option<T>
pub fn first(&self) -> Option<T>
Returns first element in the set, if any. This element is always the minimum of all elements in the set.
Trait Implementations§
source§impl<T: Domain> Extend<T> for IntSet<T>
impl<T: Domain> Extend<T> for IntSet<T>
source§fn extend<U: IntoIterator<Item = T>>(&mut self, iter: U)
fn extend<U: IntoIterator<Item = T>>(&mut self, iter: U)
Extends a collection with the contents of an iterator.
This implementation is optimized to provide the best performance when the iterator contains sorted values.
Consider using extend_unsorted()
if the iterator is known to contain unsorted values.
source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)source§impl<T: Domain> FromIterator<T> for IntSet<T>
impl<T: Domain> FromIterator<T> for IntSet<T>
source§fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self
fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self
source§impl<T: Domain + Ord> Ord for IntSet<T>
impl<T: Domain + Ord> Ord for IntSet<T>
source§impl<T: Domain + Ord> PartialOrd for IntSet<T>
impl<T: Domain + Ord> PartialOrd for IntSet<T>
impl<T: Domain> Eq for IntSet<T>
Auto Trait Implementations§
impl<T> !Freeze for IntSet<T>
impl<T> !RefUnwindSafe for IntSet<T>
impl<T> Send for IntSet<T>where
T: Send,
impl<T> !Sync for IntSet<T>
impl<T> Unpin for IntSet<T>where
T: Unpin,
impl<T> UnwindSafe for IntSet<T>where
T: 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
)