Skip to main content

BitsetDomain

Struct BitsetDomain 

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

A domain backed by a 128-bit bitmask.

Values must be non-negative integers in the range 0..128. All operations are O(1) via bitwise arithmetic and popcount. Isomorphic to the Python BitsetDomain.

Implementations§

Source§

impl BitsetDomain

Source

pub fn new(values: impl IntoIterator<Item = u32>) -> Self

Create a new bitset domain from an iterator of values.

Source

pub fn empty() -> Self

Create an empty bitset domain.

Source

pub fn range(n: u32) -> Self

Create a domain containing 0..n.

Source

pub fn bits(&self) -> u128

Raw bits access.

Source

pub fn union_with(&mut self, other: &Self)

Union with another bitset domain.

Source

pub fn intersect_with(&mut self, other: &Self)

Intersection with another bitset domain.

Source

pub fn difference_with(&mut self, other: &Self)

Difference: remove all values present in other.

Source

pub fn iter(&self) -> BitsetIter

Iterate over set bits, yielding each value.

Trait Implementations§

Source§

impl Clone for BitsetDomain

Source§

fn clone(&self) -> BitsetDomain

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for BitsetDomain

Source§

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

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

impl Domain for BitsetDomain

Source§

type Value = u32

The type of individual values in this domain.
Source§

fn size(&self) -> usize

Number of values currently in the domain.
Source§

fn contains(&self, val: &u32) -> bool

Test membership.
Source§

fn remove(&mut self, val: &u32) -> bool

Remove a value from the domain. Returns true if the value was present.
Source§

fn add(&mut self, val: &u32)

Add a value back into the domain.
Source§

fn values(&self) -> Vec<u32>

Collect all current values into a Vec.
Source§

fn iter(&self) -> impl Iterator<Item = u32>

Iterate over current values without allocating. Read more
Source§

fn singleton_value(&self) -> Option<u32>

If the domain is a singleton, return its sole value.
Source§

fn is_empty(&self) -> bool

Whether the domain is empty (wipe-out).
Source§

fn is_singleton(&self) -> bool

Whether the domain contains exactly one value.
Source§

impl PartialEq for BitsetDomain

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · 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 StructuralPartialEq for BitsetDomain

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.