Struct nanvm_lib::common::bit_subset64::BitSubset64
source · pub struct BitSubset64<T: Cast<u64> = u64>{
pub tag: u64,
pub mask: u64,
/* private fields */
}
Expand description
A bit subset of u64
.
This structure represents a subset of bits within a 64-bit unsigned integer,
defined by a specific pattern where each bit is either 0
, 1
, or S
.
0
means the bit is always0
. These bits contribute to both the tag and the mask.1
means the bit is always1
. These bits also contribute to both the tag and the mask.S
represents a superposition state, meaning the bit can be either0
or1
.
The cardinality of the set is calculated as 2^(superposition.count_ones())
, representing
the number of unique combinations possible within the superposition bits.
The following table summarizes how each field is derived:
Property | 0 | 1 | S | Description |
---|---|---|---|---|
union | 0 | 1 | 1 | items.reduce(or) |
tag | 0 | 1 | 0 | items.reduce(and) |
superposition | 0 | 0 | 1 | union ^ tag |
mask | 1 | 1 | 0 | !superposition |
Fields§
§tag: u64
Represents the intersection of all items in the subset. A pattern of bits
where a 1
in each position indicates that the corresponding bit is consistently 1
across all items, and a 0
indicates that it is not consistently 1
.
mask: u64
Identifies the bits that are constant (either 0
or 1
). A 1
in a position
indicates a fixed bit (as per the tag
), and a 0
indicates a superposition bit.
Implementations§
source§impl BitSubset64<u64>
impl BitSubset64<u64>
source§impl<T: Cast<u64>> BitSubset64<T>
impl<T: Cast<u64>> BitSubset64<T>
pub const fn from_tag_and_mask(tag: u64, mask: u64) -> Self
pub const fn from_tag_and_superposition(tag: u64, sup: u64) -> Self
pub const fn from_tag_and_union(tag: u64, union: u64) -> Self
pub const fn from_tag(tag: u64) -> Self
pub const fn has(self, value: u64) -> bool
pub const fn union(self) -> u64
pub const fn superposition(self) -> u64
pub const fn or_unchecked(self, b: Self) -> Self
pub const fn or(self, b: Self) -> Self
pub const fn and(self, b: Self) -> Self
pub const fn split(self, sub_mask: u64) -> (Self, Self)
pub const fn raw_value_to_subset_value(self, value: u64) -> u64
pub fn typed_value_to_subset_value(self, value: T) -> u64
pub fn subset_value_to_typed_value(self, set: u64) -> T
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for BitSubset64<T>
impl<T> RefUnwindSafe for BitSubset64<T>where
T: RefUnwindSafe,
impl<T> Send for BitSubset64<T>where
T: Send,
impl<T> Sync for BitSubset64<T>where
T: Sync,
impl<T> Unpin for BitSubset64<T>where
T: Unpin,
impl<T> UnwindSafe for BitSubset64<T>where
T: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> CloneToUninit for Twhere
T: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)