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>

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> IntSet<T>
where T: Domain,

Source

pub fn iter(&self) -> impl DoubleEndedIterator

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>

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 are 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 range<R>(&self, range: R) -> impl Iterator<Item = T>
where R: RangeBounds<T>,

Returns an iterator over members of this set that are in range.

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>(&mut self, iter: U)
where U: IntoIterator<Item = T>,

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>(&mut self, iter: U)
where U: IntoIterator<Item = T>,

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 subtract(&mut self, other: &IntSet<T>)

Sets the members of this set to self - 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 const fn new() -> IntSet<T>

Create a new, (empty) IntSet.

You can create a new full set with IntSet::all.

Source

pub const fn empty() -> IntSet<T>

Create a new empty set (inclusive).

Source

pub const 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 for IntSet<T>
where T: Clone,

Source§

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

Returns a duplicate 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 for IntSet<T>
where T: Domain + Debug,

Source§

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

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<(), Error>

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

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

Source§

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

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, const N: usize> From<[T; N]> for IntSet<T>
where T: Domain,

Source§

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

Converts to this type from the input type.
Source§

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

Source§

fn from_iter<I>(iter: I) -> IntSet<T>
where I: IntoIterator<Item = T>,

Creates a value from an iterator. Read more
Source§

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

Source§

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

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> Ord for IntSet<T>
where T: Domain + Ord,

Source§

fn cmp(&self, other: &IntSet<T>) -> 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> PartialEq for IntSet<T>
where T: Domain,

Source§

fn eq(&self, other: &IntSet<T>) -> 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> PartialOrd for IntSet<T>
where T: Domain + Ord,

Source§

fn partial_cmp(&self, other: &IntSet<T>) -> 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> Eq for IntSet<T>
where T: Domain,

Auto Trait Implementations§

§

impl<T> !Freeze for IntSet<T>

§

impl<T> RefUnwindSafe for IntSet<T>
where T: RefUnwindSafe,

§

impl<T> Send for IntSet<T>
where T: Send,

§

impl<T> Sync for IntSet<T>
where T: Sync,

§

impl<T> Unpin for IntSet<T>
where T: Unpin,

§

impl<T> UnwindSafe for IntSet<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S
where T: Real + Zero + Arithmetics + Clone, Swp: WhitePoint<T>, Dwp: WhitePoint<T>, D: AdaptFrom<S, Swp, Dwp, T>,

Source§

fn adapt_into_using<M>(self, method: M) -> D
where M: TransformMatrix<T>,

Convert the source color to the destination color using the specified method.
Source§

fn adapt_into(self) -> D

Convert the source color to the destination color using the bradford method by default.
Source§

impl<T> Also for T

Source§

fn also<F>(self, block: F) -> Self
where F: FnOnce(&mut Self),

Apply a function to this value and return the (possibly) modified value.
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> AnyEq for T
where T: Any + PartialEq,

Source§

fn equals(&self, other: &(dyn Any + 'static)) -> bool

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Source§

impl<T, Res> Apply<Res> for T
where T: ?Sized,

Source§

fn apply<F>(self, f: F) -> Res
where F: FnOnce(Self) -> Res, Self: Sized,

Apply a function which takes the parameter by value.
Source§

fn apply_ref<F>(&self, f: F) -> Res
where F: FnOnce(&Self) -> Res,

Apply a function which takes the parameter by reference.
Source§

fn apply_mut<F>(&mut self, f: F) -> Res
where F: FnOnce(&mut Self) -> Res,

Apply a function which takes the parameter by mutable reference.
Source§

impl<T, C> ArraysFrom<C> for T
where C: IntoArrays<T>,

Source§

fn arrays_from(colors: C) -> T

Cast a collection of colors into a collection of arrays.
Source§

impl<T, C> ArraysInto<C> for T
where C: FromArrays<T>,

Source§

fn arrays_into(self) -> C

Cast this collection of arrays into a collection of colors.
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<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for U
where T: FromCam16Unclamped<WpParam, U>,

Source§

type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar

The number type that’s used in parameters when converting.
Source§

fn cam16_into_unclamped( self, parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>, ) -> T

Converts self into C, using the provided parameters.
Source§

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

Source§

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

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

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
Source§

impl<T, C> ComponentsFrom<C> for T
where C: IntoComponents<T>,

Source§

fn components_from(colors: C) -> T

Cast a collection of colors into a collection of color components.
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromAngle<T> for T

Source§

fn from_angle(angle: T) -> T

Performs a conversion from angle.
Source§

impl<T, U> FromStimulus<U> for T
where U: IntoStimulus<T>,

Source§

fn from_stimulus(other: U) -> T

Converts other into Self, while performing the appropriate scaling, rounding and clamping.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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, U> IntoAngle<U> for T
where U: FromAngle<T>,

Source§

fn into_angle(self) -> U

Performs a conversion into T.
Source§

impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for U
where T: Cam16FromUnclamped<WpParam, U>,

Source§

type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar

The number type that’s used in parameters when converting.
Source§

fn into_cam16_unclamped( self, parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>, ) -> T

Converts self into C, using the provided parameters.
Source§

impl<T, U> IntoColor<U> for T
where U: FromColor<T>,

Source§

fn into_color(self) -> U

Convert into T with values clamped to the color defined bounds Read more
Source§

impl<T, U> IntoColorUnclamped<U> for T
where U: FromColorUnclamped<T>,

Source§

fn into_color_unclamped(self) -> U

Convert into T. The resulting color might be invalid in its color space Read more
Source§

impl<T> IntoStimulus<T> for T

Source§

fn into_stimulus(self) -> T

Converts self into T, while performing the appropriate scaling, rounding and clamping.
Source§

impl<T> NoneValue for T
where T: Default,

Source§

type NoneType = T

Source§

fn null_value() -> T

The none-equivalent value.
Source§

impl<T> NoneValue for T
where T: Default,

Source§

type NoneType = T

Source§

fn null_value() -> T

The none-equivalent value.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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> ToSmolStr for T
where T: Display + ?Sized,

Source§

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

Source§

fn to_string(&self) -> String

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

impl<T, C> TryComponentsInto<C> for T
where C: TryFromComponents<T>,

Source§

type Error = <C as TryFromComponents<T>>::Error

The error for when try_into_colors fails to cast.
Source§

fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>

Try to cast this collection of color components into a collection of colors. 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.
Source§

impl<T, U> TryIntoColor<U> for T
where U: TryFromColor<T>,

Source§

fn try_into_color(self) -> Result<U, OutOfBounds<U>>

Convert into T, returning ok if the color is inside of its defined range, otherwise an OutOfBounds error is returned which contains the unclamped color. Read more
Source§

impl<C, U> UintsFrom<C> for U
where C: IntoUints<U>,

Source§

fn uints_from(colors: C) -> U

Cast a collection of colors into a collection of unsigned integers.
Source§

impl<C, U> UintsInto<C> for U
where C: FromUints<U>,

Source§

fn uints_into(self) -> C

Cast this collection of unsigned integers into a collection of colors.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSend for T
where T: Send,

Source§

impl<T> MaybeSync for T
where T: Sync,