read_fonts::collections::int_set

Struct IntSet

Source
pub struct IntSet<T>(/* private fields */);
Available on crate feature std only.
Expand description

A fast & efficient invertible ordered set for small (up to 32-bit) unsigned integer types.

Implementations§

Source§

impl IntSet<u32>

Source

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

Source

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

Source

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>

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn iter_excluded_ranges( &self, ) -> impl Iterator<Item = RangeInclusive<T>> + '_

Returns an iterator over all disjoint ranges of values not within the set in sorted ascending order.

Source

pub fn insert(&mut self, val: T) -> bool

Adds a value to the set.

Returns true if the value was newly inserted.

Source

pub fn insert_range(&mut self, range: RangeInclusive<T>)

Add all values in range as members of this set.

Source

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.

Source

pub fn remove(&mut self, val: T) -> bool

Removes a value from the set. Returns whether the value was present in the set.

Source

pub fn remove_all<U: IntoIterator<Item = T>>(&mut self, iter: U)

Source

pub fn remove_range(&mut self, range: RangeInclusive<T>)

Removes all values in range as members of this set.

Source

pub fn union(&mut self, other: &IntSet<T>)

Sets the members of this set to the union of self and other.

Source

pub fn intersect(&mut self, other: &IntSet<T>)

Sets the members of this set to the intersection of self and other.

Source

pub fn intersects_range(&self, range: RangeInclusive<T>) -> bool

Returns true if this set contains at least one element in ‘range’.

Source

pub fn intersects_set(&self, other: &IntSet<T>) -> bool

Returns true if this set contains at least one element in ‘other’.

Source

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.

Source

pub fn last(&self) -> Option<T>

Returns the last element in the set, if any. This element is always the maximum of all elements in the set.

Source

pub fn contains(&self, val: T) -> bool

Returns true if the set contains a value.

Source

pub fn len(&self) -> u64

Returns the number of members in this set.

Source

pub fn is_empty(&self) -> bool

Return true if there are no members in this set.

Source§

impl<T> IntSet<T>

Source

pub fn empty() -> IntSet<T>

Create a new empty set (inclusive).

Source

pub fn all() -> IntSet<T>

Create a new set which contains all integers (exclusive).

Source

pub fn is_inverted(&self) -> bool

Returns true if this set is inverted (has exclusive membership).

Source

pub fn invert(&mut self)

Return the inverted version of this set.

Source

pub fn clear(&mut self)

Clears the set, removing all values.

Trait Implementations§

Source§

impl<T: Clone> Clone for IntSet<T>

Source§

fn clone(&self) -> IntSet<T>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug> Debug for IntSet<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T> Default for IntSet<T>

Source§

fn default() -> IntSet<T>

Returns the “default value” for a type. Read more
Source§

impl<T> Display for IntSet<T>
where T: Domain + Display,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Domain> Extend<T> for IntSet<T>

Source§

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)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Source§

impl<T: Domain, const N: usize> From<[T; N]> for IntSet<T>

Source§

fn from(value: [T; N]) -> Self

Converts to this type from the input type.
Source§

impl<T: Domain> FromIterator<T> for IntSet<T>

Source§

fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self

Creates a value from an iterator. Read more
Source§

impl<T: Domain> Hash for IntSet<T>

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<T: Domain + Ord> Ord for IntSet<T>

Source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<T: Domain> PartialEq for IntSet<T>

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T: Domain + Ord> PartialOrd for IntSet<T>

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.