Struct IntSet
pub struct IntSet<T>(/* private fields */);Expand description
A fast & efficient invertible ordered set for small (up to 32-bit) unsigned integer types.
Implementations§
§impl IntSet<u32>
impl IntSet<u32>
pub 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
pub 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
pub 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
§impl<T> IntSet<T>where
T: Domain,
impl<T> IntSet<T>where
T: Domain,
pub fn iter(&self) -> impl DoubleEndedIterator
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.
pub fn inclusive_iter(&self) -> Option<impl DoubleEndedIterator>
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.
pub 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 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.
pub fn range<R>(&self, range: R) -> impl Iterator<Item = T>where
R: RangeBounds<T>,
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.
pub 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.
pub fn iter_excluded_ranges(&self) -> impl Iterator<Item = RangeInclusive<T>>
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.
pub 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.
pub 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.
pub fn extend_unsorted<U>(&mut self, iter: U)where
U: IntoIterator<Item = T>,
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.
pub 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>(&mut self, iter: U)where
U: IntoIterator<Item = T>,
pub 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.
pub 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.
pub 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.
pub 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’.
pub 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’.
pub 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.
§impl<T> IntSet<T>
impl<T> IntSet<T>
pub const fn new() -> IntSet<T>
pub const fn new() -> IntSet<T>
Create a new, (empty) IntSet.
You can create a new full set with IntSet::all.
pub fn is_inverted(&self) -> bool
pub fn is_inverted(&self) -> bool
Returns true if this set is inverted (has exclusive membership).
pub fn invert(&mut self)
pub fn invert(&mut self)
Return the inverted version of this set.
pub fn clear(&mut self)
pub fn clear(&mut self)
Clears the set, removing all values.
Trait Implementations§
§impl<T> Extend<T> for IntSet<T>where
T: Domain,
impl<T> Extend<T> for IntSet<T>where
T: Domain,
§fn extend<U>(&mut self, iter: U)where
U: IntoIterator<Item = T>,
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)
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)§impl<T> FromIterator<T> for IntSet<T>where
T: Domain,
impl<T> FromIterator<T> for IntSet<T>where
T: Domain,
§fn from_iter<I>(iter: I) -> IntSet<T>where
I: IntoIterator<Item = T>,
fn from_iter<I>(iter: I) -> IntSet<T>where
I: IntoIterator<Item = T>,
§impl<T> Ord for IntSet<T>
impl<T> Ord for IntSet<T>
§impl<T> PartialOrd for IntSet<T>
impl<T> PartialOrd for IntSet<T>
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 Swhere
T: Real + Zero + Arithmetics + Clone,
Swp: WhitePoint<T>,
Dwp: WhitePoint<T>,
D: AdaptFrom<S, Swp, Dwp, T>,
impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere
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) -> Dwhere
M: TransformMatrix<T>,
fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<T>,
Source§fn adapt_into(self) -> D
fn adapt_into(self) -> D
§impl<T> AnyEq for T
impl<T> AnyEq for T
§impl<T, Res> Apply<Res> for Twhere
T: ?Sized,
impl<T, Res> Apply<Res> for Twhere
T: ?Sized,
Source§impl<T, C> ArraysFrom<C> for Twhere
C: IntoArrays<T>,
impl<T, C> ArraysFrom<C> for Twhere
C: IntoArrays<T>,
Source§fn arrays_from(colors: C) -> T
fn arrays_from(colors: C) -> T
Source§impl<T, C> ArraysInto<C> for Twhere
C: FromArrays<T>,
impl<T, C> ArraysInto<C> for Twhere
C: FromArrays<T>,
Source§fn arrays_into(self) -> C
fn arrays_into(self) -> C
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<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for Uwhere
T: FromCam16Unclamped<WpParam, U>,
impl<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for Uwhere
T: FromCam16Unclamped<WpParam, U>,
Source§type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar
type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar
parameters when converting.Source§fn cam16_into_unclamped(
self,
parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>,
) -> T
fn cam16_into_unclamped( self, parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>, ) -> T
self into C, using the provided parameters.Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<T, C> ComponentsFrom<C> for Twhere
C: IntoComponents<T>,
impl<T, C> ComponentsFrom<C> for Twhere
C: IntoComponents<T>,
Source§fn components_from(colors: C) -> T
fn components_from(colors: C) -> T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> FromAngle<T> for T
impl<T> FromAngle<T> for T
Source§fn from_angle(angle: T) -> T
fn from_angle(angle: T) -> T
angle.Source§impl<T, U> FromStimulus<U> for Twhere
U: IntoStimulus<T>,
impl<T, U> FromStimulus<U> for Twhere
U: IntoStimulus<T>,
Source§fn from_stimulus(other: U) -> T
fn from_stimulus(other: U) -> T
other into Self, while performing the appropriate scaling,
rounding and clamping.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T, U> IntoAngle<U> for Twhere
U: FromAngle<T>,
impl<T, U> IntoAngle<U> for Twhere
U: FromAngle<T>,
Source§fn into_angle(self) -> U
fn into_angle(self) -> U
T.§impl<State, Message> IntoBoot<State, Message> for State
impl<State, Message> IntoBoot<State, Message> for State
§fn into_boot(self) -> (State, Task<Message>)
fn into_boot(self) -> (State, Task<Message>)
Application.Source§impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for Uwhere
T: Cam16FromUnclamped<WpParam, U>,
impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for Uwhere
T: Cam16FromUnclamped<WpParam, U>,
Source§type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar
type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar
parameters when converting.Source§fn into_cam16_unclamped(
self,
parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>,
) -> T
fn into_cam16_unclamped( self, parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>, ) -> T
self into C, using the provided parameters.Source§impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
Source§fn into_color(self) -> U
fn into_color(self) -> U
Source§impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
Source§fn into_color_unclamped(self) -> U
fn into_color_unclamped(self) -> U
Source§impl<T> IntoStimulus<T> for T
impl<T> IntoStimulus<T> for T
Source§fn into_stimulus(self) -> T
fn into_stimulus(self) -> T
self into T, while performing the appropriate scaling,
rounding and clamping.§impl<T> NoneValue for Twhere
T: Default,
impl<T> NoneValue for Twhere
T: Default,
type NoneType = T
§fn null_value() -> T
fn null_value() -> T
Source§impl<T, C> TryComponentsInto<C> for Twhere
C: TryFromComponents<T>,
impl<T, C> TryComponentsInto<C> for Twhere
C: TryFromComponents<T>,
Source§type Error = <C as TryFromComponents<T>>::Error
type Error = <C as TryFromComponents<T>>::Error
try_into_colors fails to cast.Source§fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>
fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>
Source§impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
Source§fn try_into_color(self) -> Result<U, OutOfBounds<U>>
fn try_into_color(self) -> Result<U, OutOfBounds<U>>
OutOfBounds error is returned which contains
the unclamped color. Read more