Struct sudoku_variants::util::USizeSet[][src]

pub struct USizeSet { /* fields omitted */ }

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

impl USizeSet[src]

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

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.

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

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.

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

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.

pub fn min(&self) -> usize[src]

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

pub fn max(&self) -> usize[src]

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

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

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.

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

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.

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

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.

pub fn clear(&mut self)[src]

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

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

Notable traits for USizeSetIter<'a>

impl<'a> Iterator for USizeSetIter<'a> type Item = usize;
[src]

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

pub fn is_empty(&self) -> bool[src]

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

pub fn len(&self) -> usize[src]

Returns the number of elements contained in this set.

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

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.

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

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.

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

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.

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

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.

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

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.

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

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.

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

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.

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

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

impl BitAnd<&'_ USizeSet> for USizeSet[src]

type Output = USizeSet

The resulting type after applying the & operator.

impl BitAnd<&'_ USizeSet> for &USizeSet[src]

type Output = USizeSet

The resulting type after applying the & operator.

impl BitAndAssign<&'_ USizeSet> for USizeSet[src]

impl BitAndAssign<&'_ USizeSet> for &mut USizeSet[src]

impl BitOr<&'_ USizeSet> for USizeSet[src]

type Output = USizeSet

The resulting type after applying the | operator.

impl BitOr<&'_ USizeSet> for &USizeSet[src]

type Output = USizeSet

The resulting type after applying the | operator.

impl BitOrAssign<&'_ USizeSet> for USizeSet[src]

impl BitOrAssign<&'_ USizeSet> for &mut USizeSet[src]

impl BitXor<&'_ USizeSet> for USizeSet[src]

type Output = USizeSet

The resulting type after applying the ^ operator.

impl BitXor<&'_ USizeSet> for &USizeSet[src]

type Output = USizeSet

The resulting type after applying the ^ operator.

impl BitXorAssign<&'_ USizeSet> for USizeSet[src]

impl BitXorAssign<&'_ USizeSet> for &mut USizeSet[src]

impl Clone for USizeSet[src]

impl Debug for USizeSet[src]

impl Eq for USizeSet[src]

impl PartialEq<USizeSet> for USizeSet[src]

impl StructuralEq for USizeSet[src]

impl StructuralPartialEq for USizeSet[src]

impl Sub<&'_ USizeSet> for USizeSet[src]

type Output = USizeSet

The resulting type after applying the - operator.

impl Sub<&'_ USizeSet> for &USizeSet[src]

type Output = USizeSet

The resulting type after applying the - operator.

impl SubAssign<&'_ USizeSet> for USizeSet[src]

impl SubAssign<&'_ USizeSet> for &mut USizeSet[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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