pub struct TriVec { /* private fields */ }Expand description
位切片的三值向量。
相等语义按值:两个 TriVec 只要长度与逐元素取值一致就相等,
与内部是否分配了全零的 unknowns 平面无关。
Implementations§
Source§impl TriVec
impl TriVec
Sourcepub fn from_binary(ones: Vec<u64>, len: usize) -> Self
pub fn from_binary(ones: Vec<u64>, len: usize) -> Self
零拷贝接管二进制位平面:ones 的位为 1 表示 True,0 表示 False。
ones 必须至少覆盖 len 位;多余字会被截断,末尾多余位会被清零。
§Panics
ones 字数不足时 panic;边界输入请用 TriVec::try_from_binary。
Sourcepub fn try_from_binary(ones: Vec<u64>, len: usize) -> Result<Self, TriVecError>
pub fn try_from_binary(ones: Vec<u64>, len: usize) -> Result<Self, TriVecError>
同 TriVec::from_binary,但字数不足时返回错误。
Sourcepub fn from_bools(bits: &[bool]) -> Self
pub fn from_bools(bits: &[bool]) -> Self
从 bool 切片打包。
Sourcepub fn from_ternary(values: &[Ternary]) -> Self
pub fn from_ternary(values: &[Ternary]) -> Self
从标量三值切片打包。
Sourcepub fn try_set(&mut self, i: usize, value: Ternary) -> Result<(), TriVecError>
pub fn try_set(&mut self, i: usize, value: Ternary) -> Result<(), TriVecError>
写第 i 个三值;越界返回错误。
Sourcepub fn count_unknowns(&self) -> usize
pub fn count_unknowns(&self) -> usize
Unknown 的个数。
Sourcepub fn and_assign(
&mut self,
other: &Self,
alg: Algebra,
) -> Result<(), ShapeError>
pub fn and_assign( &mut self, other: &Self, alg: Algebra, ) -> Result<(), ShapeError>
原地与。K3/Ł3 用格序,B3 用毒值。
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TriVec
impl RefUnwindSafe for TriVec
impl Send for TriVec
impl Sync for TriVec
impl Unpin for TriVec
impl UnsafeUnpin for TriVec
impl UnwindSafe for TriVec
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
Mutably borrows from an owned value. Read more