USizeSet

Struct USizeSet 

Source
pub struct USizeSet { /* private fields */ }
Expand description

A set of usize that is implemented as a bit vector. Each usize that is in the range of possible elements is represented by one bit in a vector of numbers. This generally has better performance than a HashSet.

Implementations§

Source§

impl USizeSet

Source

pub fn new(min: usize, max: usize) -> USizeSetResult<USizeSet>

Creates a new, empty USizeSet with the given (inclusive) bounds.

§Arguments
  • min: The minimum value that can be contained in the created set. Any values lower than that will yield a USizeSetError::OutOfBounds if inserted or removed. Must be less than or equal to max.
  • max: The maximum value that can be contained in the created set. Any values higher than that will yield a USizeSetError::OutOfBounds if inserted or removed. Must be greater than or equal to min.
§Errors

If min > max. In that case, a USizeSetError::InvalidBounds is returned.

Source

pub fn singleton( min: usize, max: usize, content: usize, ) -> USizeSetResult<USizeSet>

Creates a new singleton USizeSet with the given (inclusive) bounds. The set contains one element, which is specified by content.

§Arguments
  • min: The minimum value that can be contained in the created set. Any values lower than that will yield a USizeSetError::OutOfBounds if inserted or removed. Must be less than or equal to max.
  • max: The maximum value that can be contained in the created set. Any values higher than that will yield a USizeSetError::OutOfBounds if inserted or removed. Must be greater than or equal to min.
  • content: The only element contained by the created set. Must be within the bounds.
§Errors
  • USizeSetError::InvalidBounds: If min > max.
  • USizeSetError::OutOfBounds: If content < min or content > max.
Source

pub fn range(min: usize, max: usize) -> USizeSetResult<USizeSet>

Creates a new USizeSet that includes all numbers in the given (inclusive) bounds. Note that these bounds also apply later.

§Arguments
  • min: The minimum value contained in the created set, which is also the minimum that can be contained. Any values lower than this will yield a USizeSetError::OutOfBounds if inserted or removed. Must be less than or equal to max.
  • max: The maximum value contained in the created set, which is also the maximum value that can be contained. Any values higher than this will yield a USizeSetError::OutOfBounds if inserted or removed. Must be greater than or equal to min.
§Errors

If min > max. In that case, a USizeSetError::InvalidBounds is returned.

Source

pub fn min(&self) -> usize

Returns the minimum value that this set can contain (inclusive).

Source

pub fn max(&self) -> usize

Returns the maximum value that this set can contain (inclusive).

Source

pub fn contains(&self, number: usize) -> bool

Indicates whether this set contains the given number, in which case this method returns true. If it is not contained or outside the bounds, false will be returned.

Source

pub fn insert(&mut self, number: usize) -> USizeSetResult<bool>

Inserts the given number into this set, such that USizeSet::contains returns true for this number afterwards. Note that it must be within the bounds provided at construction time.

This method returns true if the set has changed (i.e. the number was not present before) and false otherwise.

§Errors

If number is less than USizeSet::min or greater than USizeSet::max. In that case, USizeSetError::OutOfBounds is returned.

Source

pub fn remove(&mut self, number: usize) -> USizeSetResult<bool>

Removes the given number from this set, such that USizeSet::contains returns false for this number afterwards. Note that it must be within the bounds provided at construction time.

This method returns true if the set has changed (i.e. the number was present before) and false otherwise.

§Errors

If number is less than USizeSet::min or greater than USizeSet::max. In that case, USizeSetError::OutOfBounds is returned.

Source

pub fn clear(&mut self)

Removes all numbers from this set, such that USizeSet::contains will return false for all inputs and USizeSet::is_empty will return true.

Source

pub fn iter(&self) -> USizeSetIter<'_>

Returns an iterator over the numbers contained in this set in ascending order.

Source

pub fn is_empty(&self) -> bool

Indicates whether this set is empty, i.e. contains no numbers. If this method returns true, USizeSet::contains will return false for all inputs.

Source

pub fn len(&self) -> usize

Returns the number of elements contained in this set.

Source

pub fn union_assign(&mut self, other: &USizeSet) -> USizeSetResult<bool>

Computes the set union between this and the given set and stores the result in this set. The bounds of this set and other must be equal.

USizeSet implements BitOrAssign as syntactic sugar for this operation. Note that that implementation panics instead of returning potential errors.

§Returns

True, if and only if this set changed as a result of the operation.

§Errors

If either the minimum or maximum of this set and other are different. In that case, USizeError::DifferentBounds is returned.

Source

pub fn union(&self, other: &USizeSet) -> USizeSetResult<USizeSet>

Computes the set union between this and the given set and stores the result in a new set which is returned. The bounds of this set and other must be equal.

USizeSet implements BitOr as syntactic sugar for this operation. Note that that implementation panics instead of returning potential errors.

§Errors

If the minimum or maximum of this set and other are different. In that case, USizeError::DifferentBounds is returned.

Source

pub fn intersect_assign(&mut self, other: &USizeSet) -> USizeSetResult<bool>

Computes the set intersection between this and the given set and stores the result in this set. The bounds of this set and other must be equal.

USizeSet implements BitAndAssign as syntactic sugar for this operation. Note that that implementation panics instead of returning potential errors.

§Returns

True, if and only if this set changed as a result of the operation.

§Errors

If the minimum or maximum of this set and other are different. In that case, USizeError::DifferentBounds is returned.

Source

pub fn intersect(&self, other: &USizeSet) -> USizeSetResult<USizeSet>

Computes the set intersection between this and the given set and stores the result in a new set which is returned. The bounds of this set and other must be equal.

USizeSet implements BitAnd as syntactic sugar for this operation. Note that that implementation panics instead of returning potential errors.

§Errors

If the minimum or maximum of this set and other are different. In that case, USizeError::DifferentBounds is returned.

Source

pub fn difference_assign(&mut self, other: &USizeSet) -> USizeSetResult<bool>

Computes the set difference between this and the given set and stores the result in this set. The bounds of this set and other must be equal. other acts as the right-hand-side, meaning its elements are removed from the result.

USizeSet implements SubAssign as syntactic sugar for this operation. Note that that implementation panics instead of returning potential errors.

§Returns

True, if and only if this set changed as a result of the operation.

§Errors

If the minimum or maximum of this set and other are different. In that case, USizeError::DifferentBounds is returned.

Source

pub fn difference(&self, other: &USizeSet) -> USizeSetResult<USizeSet>

Computes the set difference between this and the given set and stores the result in a new set which is returned. The bounds of this set and other must be equal.

USizeSet implements Sub as syntactic sugar for this operation. Note that that implementation panics instead of returning potential errors.

§Errors

If the minimum or maximum of this set and other are different. In that case, USizeError::DifferentBounds is returned.

Source

pub fn symmetric_difference_assign( &mut self, other: &USizeSet, ) -> USizeSetResult<bool>

Computes the symmetric set difference between this and the given set and stores the result in this set. The bounds of this set and other must be equal.

USizeSet implements BitXorAssign as syntactic sugar for this operation. Note that that implementation panics instead of returning potential errors.

§Returns

True, if and only if this set changed as a result of the operation.

§Errors

If the minimum or maximum of this set and other are different. In that case, USizeError::DifferentBounds is returned.

Source

pub fn symmetric_difference(&self, other: &USizeSet) -> USizeSetResult<USizeSet>

Computes the symmetric set difference between this and the given set and stores the result in a new set which is returned. The bounds of this set and other must be equal.

USizeSet implements BitXor as syntactic sugar for this operation. Note that that implementation panics instead of returning potential errors.

§Errors

If the minimum or maximum of this set and other are different. In that case, USizeError::DifferentBounds is returned.

Trait Implementations§

Source§

impl BitAnd<&USizeSet> for USizeSet

Source§

type Output = USizeSet

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: &USizeSet) -> USizeSet

Performs the & operation. Read more
Source§

impl BitAnd for &USizeSet

Source§

type Output = USizeSet

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: &USizeSet) -> USizeSet

Performs the & operation. Read more
Source§

impl BitAndAssign<&USizeSet> for &mut USizeSet

Source§

fn bitand_assign(&mut self, rhs: &USizeSet)

Performs the &= operation. Read more
Source§

impl BitAndAssign<&USizeSet> for USizeSet

Source§

fn bitand_assign(&mut self, rhs: &USizeSet)

Performs the &= operation. Read more
Source§

impl BitOr<&USizeSet> for USizeSet

Source§

type Output = USizeSet

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: &USizeSet) -> USizeSet

Performs the | operation. Read more
Source§

impl BitOr for &USizeSet

Source§

type Output = USizeSet

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: &USizeSet) -> USizeSet

Performs the | operation. Read more
Source§

impl BitOrAssign<&USizeSet> for &mut USizeSet

Source§

fn bitor_assign(&mut self, rhs: &USizeSet)

Performs the |= operation. Read more
Source§

impl BitOrAssign<&USizeSet> for USizeSet

Source§

fn bitor_assign(&mut self, rhs: &USizeSet)

Performs the |= operation. Read more
Source§

impl BitXor<&USizeSet> for USizeSet

Source§

type Output = USizeSet

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: &USizeSet) -> USizeSet

Performs the ^ operation. Read more
Source§

impl BitXor for &USizeSet

Source§

type Output = USizeSet

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: &USizeSet) -> USizeSet

Performs the ^ operation. Read more
Source§

impl BitXorAssign<&USizeSet> for &mut USizeSet

Source§

fn bitxor_assign(&mut self, rhs: &USizeSet)

Performs the ^= operation. Read more
Source§

impl BitXorAssign<&USizeSet> for USizeSet

Source§

fn bitxor_assign(&mut self, rhs: &USizeSet)

Performs the ^= operation. Read more
Source§

impl Clone for USizeSet

Source§

fn clone(&self) -> USizeSet

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 Debug for USizeSet

Source§

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

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

impl PartialEq for USizeSet

Source§

fn eq(&self, other: &USizeSet) -> 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 Sub<&USizeSet> for USizeSet

Source§

type Output = USizeSet

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &USizeSet) -> USizeSet

Performs the - operation. Read more
Source§

impl Sub for &USizeSet

Source§

type Output = USizeSet

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &USizeSet) -> USizeSet

Performs the - operation. Read more
Source§

impl SubAssign<&USizeSet> for &mut USizeSet

Source§

fn sub_assign(&mut self, rhs: &USizeSet)

Performs the -= operation. Read more
Source§

impl SubAssign<&USizeSet> for USizeSet

Source§

fn sub_assign(&mut self, rhs: &USizeSet)

Performs the -= operation. Read more
Source§

impl Eq for USizeSet

Source§

impl StructuralPartialEq for USizeSet

Auto Trait Implementations§

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, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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, 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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V