Struct Set32

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

This structure implemts a bitset with a maximum capacity of $capa bits. The structure requires no dynamic allocation and it is therefore fully copiable

Implementations§

Source§

impl Set32

Source

pub const fn empty() -> Self

Creates an empty set

Source

pub const fn full() -> Self

Creates a set where all items are present

Source

pub const fn singleton(x: usize) -> Self

Creates a singleton set comprising one single item

Source

pub const fn capacity(self) -> usize

Returns the capacity of the bitset

Source

pub fn len(self) -> usize

Returns the lenght of the set. That is the number of itemes present (value of the bit is 1) in the set

Source

pub fn is_empty(self) -> bool

Returns true iff the set is empty

Source

pub const fn contains(self, x: usize) -> bool

Returns true iff the set contains item ‘x’

Source

pub const fn add(self, x: usize) -> Self

Returns a new set where item x is present in the set

Source

pub fn add_inplace(&mut self, x: usize) -> &mut Self

Adds the item x to this set

Source

pub const fn remove(self, x: usize) -> Self

Returns a new set where item x is absent from the set

Source

pub fn remove_inplace(&mut self, x: usize) -> &mut Self

Removes x from the current set

Source

pub fn union(self, other: Self) -> Self

Returns the union of both sets

Source

pub fn union_inplace(&mut self, other: &Self) -> &mut Self

Updates this set so that it contains the union of self and other

Source

pub fn inter(self, other: Self) -> Self

Returns a set which is the intersection of both sets

Source

pub fn inter_inplace(&mut self, other: &Self) -> &mut Self

Updates this set so that it contains the intersection of self and other

Source

pub fn diff(self, other: Self) -> Self

Returns a set which is the difference of the two sets

Source

pub fn diff_inplace(&mut self, other: &Self) -> &mut Self

Updates this set so that it contains the difference of self and other

Source

pub fn symmetric_difference(self, other: Self) -> Self

Returns a set which is the exclusive or of the two sets

Source

pub fn symmetric_difference_inplace(&mut self, other: &Self) -> &mut Self

Updates this set so that it contains the exclusive or of self and other

Source

pub fn flip(self) -> Self

Flips all the bits of self (all members are removed, all absent are added)

Source

pub fn flip_inplace(&mut self) -> &mut Self

Updates this set so that it contains the negation of self

Source

pub fn contains_all(self, other: Self) -> bool

Returns true iff this set contains all the elements of the other set. (self is a superset of other).

Source

pub fn disjoint(self, other: Self) -> bool

Return true iff the two sets are disjoint

Source

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

Returns true iff the intersects with other set

Source

pub fn iter(&self) -> impl Iterator<Item = usize> + '_

Returns an iterator that goes over all the items present in this set

Source

pub fn ones(&self) -> impl Iterator<Item = usize> + '_

Returns an iterator that goes over all the items present in this set

Source

pub fn zeroes(&self) -> impl Iterator<Item = usize> + '_

Returns an iterator that goes over all the items absent from this set

Source

pub fn subsets(&self, of_size: usize) -> impl Iterator<Item = Self> + '_

Returns an iterator that goes over all the items absent from this set Requires the alloc feature

Source

pub const fn inc(self) -> Self

Returns the next value when considering the bitset as a large integer value and incrementing it by one.

Source

pub fn inc_inplace(&mut self) -> &mut Self

Consider the bitset as a large integer value and increments it by one

Trait Implementations§

Source§

impl BitAnd for Set32

Source§

type Output = Set32

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: Self) -> Self::Output

Performs the & operation. Read more
Source§

impl BitAndAssign for Set32

Source§

fn bitand_assign(&mut self, rhs: Self)

Performs the &= operation. Read more
Source§

impl BitOr for Set32

Source§

type Output = Set32

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: Self) -> Self::Output

Performs the | operation. Read more
Source§

impl BitOrAssign for Set32

Source§

fn bitor_assign(&mut self, rhs: Self)

Performs the |= operation. Read more
Source§

impl BitXor for Set32

Source§

type Output = Set32

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: Self) -> Self::Output

Performs the ^ operation. Read more
Source§

impl BitXorAssign for Set32

Source§

fn bitxor_assign(&mut self, rhs: Self)

Performs the ^= operation. Read more
Source§

impl Clone for Set32

Source§

fn clone(&self) -> Set32

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

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Set32

Source§

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

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

impl Default for Set32

Source§

fn default() -> Self

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

impl Display for Set32

Source§

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

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

impl From<[u32; 1]> for Set32

Source§

fn from(x: [u32; 1]) -> Set32

Converts to this type from the input type.
Source§

impl From<Set32> for [u32; 1]

Source§

fn from(x: Set32) -> [u32; 1]

Converts to this type from the input type.
Source§

impl From<Set32> for u32

Source§

fn from(x: Set32) -> u32

Converts to this type from the input type.
Source§

impl From<u32> for Set32

Source§

fn from(x: u32) -> Set32

Converts to this type from the input type.
Source§

impl Hash for Set32

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 Not for Set32

Source§

type Output = Set32

The resulting type after applying the ! operator.
Source§

fn not(self) -> Self::Output

Performs the unary ! operation. Read more
Source§

impl Ord for Set32

Source§

fn cmp(&self, other: &Set32) -> 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 PartialEq for Set32

Source§

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

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

const 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 PartialOrd for Set32

Source§

fn partial_cmp(&self, other: &Set32) -> 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 Copy for Set32

Source§

impl Eq for Set32

Source§

impl StructuralPartialEq for Set32

Auto Trait Implementations§

§

impl Freeze for Set32

§

impl RefUnwindSafe for Set32

§

impl Send for Set32

§

impl Sync for Set32

§

impl Unpin for Set32

§

impl UnwindSafe for Set32

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> 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, 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.