BitSet128

Struct BitSet128 

Source
pub struct BitSet128(/* private fields */);
Available on crate feature b128 only.
Expand description

A set of 128 bits.

Implementations§

Source§

impl BitSet128

Source

pub const CAPACITY: usize = 128usize

The capacity of a BitSet128.

Source

pub const fn new() -> Self

Creates an empty set.

Source

pub const fn unit(index: usize) -> Self

Creates a set containing with only the bit at index set.

If index >=Self::CAPACITY, the resulting set will be empty.

Source

pub const fn all() -> Self

Creates a set with all bits set.

Source

pub const fn from_bits(bits: u128) -> Self

Creates a set with the given bits.

Source

pub const fn bits(self) -> u128

Returns the underlying bits of the set.

Source

pub const fn complement(self) -> Self

Creates a new set that complements self. This is the const alternative to Neg::neg or Not::not for BitSet128s.

Source

pub const fn intersection(self, rhs: Self) -> Self

Creates a new set with values that are in both self and rhs. This is the const alternative to BitAnd::bitand for BitSet128s.

Source

pub const fn union(self, rhs: Self) -> Self

Creates a new set with values that are in self or rhs. This is the const alternative to BitOr::bitor for BitSet128s.

Source

pub const fn difference(self, rhs: Self) -> Self

Creates a new set with values that are in self, but not in rhs. This is the const alternative to Sub::sub for BitSet128s.

Source

pub const fn symmetric_difference(self, rhs: Self) -> Self

Creates a new set with values that are in self or rhs, but not in both. This is the const alternative to BitXor::bitxor for BitSet128s.

Source

pub const fn is(self, rhs: Self) -> bool

Returns true if self is equal to rhs, i.e., both sets have the same exact values. This is the const alternative to PartialEq::eq for BitSet128s.

Source

pub const fn is_not(self, rhs: Self) -> bool

Returns true if self is not equal to rhs, i.e., the sets do not have exactly the same values. This is the const alternative to PartialEq::ne for BitSet128s.

Source

pub const fn is_disjoint(self, rhs: Self) -> bool

Returns true if self has no elements in common with rhs. This is equivalent to checking for an empty intersection.

Source

pub const fn is_subset(self, rhs: Self) -> bool

Returns true if the set is a subset of another, i.e., rhs contains at least all the values in self.

Source

pub const fn is_strict_subset(self, rhs: Self) -> bool

Returns true if the set is a strict subset of another, i.e., rhs contains all the values in self and is larger than self.

Source

pub const fn is_superset(self, rhs: Self) -> bool

Returns true if the set is a superset of another, i.e., self contains at least all the values in rhs.

Source

pub const fn is_strict_superset(self, rhs: Self) -> bool

Returns true if the set is a strict superset of another, i.e., self contains all the values in rhs and is larger than rhs.

Source

pub const fn is_empty(self) -> bool

Returns true if the set contains no elements.

Source

pub const fn is_full(self) -> bool

Returns true if the set contains all Self::CAPACITY elements.

Source

pub const fn len(self) -> usize

Returns the number of elements in the set.

Source

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

Returns true if the bit at index is set.

Source

pub const fn get(self, index: usize) -> bool

Gets the bit at index.

If index >=Self::CAPACITY, this will simply return false.

Source

pub const fn min_index(self) -> usize

Returns the index of the least significant bit that is set.

If no bits are set, this returns Self::CAPACITY.

Source

pub const fn max_index(self) -> usize

Returns the index of the most significant bit that is set.

§Panics

Panics if no bits are set. For a non-panicking alternative, see max_index_checked.

Source

pub const fn max_index_checked(self) -> Option<usize>

Returns the index of the most significant bit that is set, or None if no bits are set.

Source

pub const fn clear(&mut self)

Clears the set, removing all values.

Source

pub const fn masked_0_to_i(self, index: usize) -> Self

Creates a copy of this set that only has values less than index.

§Panics

Panics if index >=Self::CAPACITY.

Source

pub const fn mask_0_to_i(&mut self, index: usize)

Removes any bits with indices outside the range 0..index.

§Panics

Panics if index >=Self::CAPACITY.

Source

pub const fn masked_i_to_128(self, index: usize) -> Self

Creates a copy of this set that only has bits with indices greater than or equal to index.

§Panics

Panics if index >=Self::CAPACITY.

Source

pub const fn mask_i_to_128(&mut self, index: usize)

Removes any bits with indices outside the range index..128.

§Panics

Panics if index >=Self::CAPACITY.

Source

pub const fn cleared_0_to_i(self, index: usize) -> Self

Creates a copy of this set without the bits with indices in the range 0..index.

§Panics

Panics if index >=Self::CAPACITY.

Source

pub const fn clear_0_to_i(&mut self, index: usize)

Clears bits 0..index, keeping bits index..128 in their original states.

§Panics

Panics if index >=Self::CAPACITY.

Source

pub const fn cleared_i_to_128(self, index: usize) -> Self

Creates a copy of this set without the bits with indices in the range index..128.

§Panics

Panics if index >=Self::CAPACITY.

Source

pub const fn clear_i_to_128(&mut self, index: usize)

Clears bits index..128, keeping bits 0..index in their original states.

§Panics

Panics if index >=Self::CAPACITY.

Source

pub const fn insert_quiet(&mut self, index: usize)

Sets the bit at index to 1.

If you would like to know if the insertion succeeded, use insert instead.

Source

pub const fn insert(&mut self, index: usize) -> bool

Sets the bit at index to 1. Returns whether the bit was not already set.

If the return value is not needed, use insert_quiet instead.

Source

pub const fn replace_quiet(&mut self, index: usize, bit: bool)

Sets the bit at index to bit.

If you would like to know the old value of the bit, use replace instead.

Source

pub const fn replace(&mut self, index: usize, bit: bool) -> bool

Sets the bit at index to bit.

If the return value is not needed, use replace_quiet instead.

Source

pub const fn remove_quiet(&mut self, index: usize)

Sets the bit at index to 0.

If you would like to know if the removal succeeded, use remove instead.

Source

pub const fn remove(&mut self, index: usize) -> bool

Sets the bit at index to 0. Returns whether the bit was set.

If the return value is not needed, use remove_quiet instead.

Source§

impl BitSet128

Source

pub const fn iter_indices<Direction>(&self) -> BitSetIndices128<'_, Direction>
where for<'a> BitSetIndices128<'a, Direction>: Iterator<Item = usize>,

Creates an iterator over the indices of the bits that are set in the set.

Source§

impl BitSet128

Source

pub const fn iter_bits<Direction>(&self) -> BitSetIter128<'_, Direction>
where for<'a> BitSetIter128<'a, Direction>: Iterator<Item = bool>,

Creates an iterator over the bits of the set.

Trait Implementations§

Source§

impl BitAnd for BitSet128

Source§

type Output = BitSet128

The resulting type after applying the & operator.
Source§

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

Performs the & operation. Read more
Source§

impl BitAndAssign for BitSet128

Source§

fn bitand_assign(&mut self, rhs: Self)

Performs the &= operation. Read more
Source§

impl BitOr for BitSet128

Source§

type Output = BitSet128

The resulting type after applying the | operator.
Source§

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

Performs the | operation. Read more
Source§

impl BitOrAssign for BitSet128

Source§

fn bitor_assign(&mut self, rhs: Self)

Performs the |= operation. Read more
Source§

impl BitXor for BitSet128

Source§

type Output = BitSet128

The resulting type after applying the ^ operator.
Source§

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

Performs the ^ operation. Read more
Source§

impl BitXorAssign for BitSet128

Source§

fn bitxor_assign(&mut self, rhs: Self)

Performs the ^= operation. Read more
Source§

impl Clone for BitSet128

Source§

fn clone(&self) -> BitSet128

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 BitSet128

Source§

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

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

impl Default for BitSet128

Source§

fn default() -> BitSet128

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

impl From<BitSet128> for u128

Source§

fn from(value: BitSet128) -> Self

Converts to this type from the input type.
Source§

impl From<u128> for BitSet128

Source§

fn from(value: u128) -> Self

Converts to this type from the input type.
Source§

impl Hash for BitSet128

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 Neg for BitSet128

Source§

type Output = BitSet128

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
Source§

impl Not for BitSet128

Source§

type Output = BitSet128

The resulting type after applying the ! operator.
Source§

fn not(self) -> Self::Output

Performs the unary ! operation. Read more
Source§

impl PartialEq for BitSet128

Source§

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

Source§

type Output = BitSet128

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl SubAssign for BitSet128

Source§

fn sub_assign(&mut self, rhs: Self)

Performs the -= operation. Read more
Source§

impl Copy for BitSet128

Source§

impl Eq for BitSet128

Source§

impl StructuralPartialEq for BitSet128

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.