pub struct BitSet { /* private fields */ }
Expand description
Bit set。
Implementation notes
&
|
^
について、左辺の capacity を持つ新たな BitSet
を返すため、可換でない。
可換にすることにすると、 x = x | y
と x |= y
の整合性を取りたくなり、|=
の操作でも capacity を変化させるのが妥当になるが、あまりうれしくなさそう?
capacity は暗黙に変わらないような設計にしているが、eq()
などでは capacity
は無視するべき? 立っているビットが同じかを比較するときに eq()
で済むのがうれしいか、cmp().is_eq()
にするか? そこを短くするために capacity
の比較を別でやる必要がある方がつらいか?
u128
での実装 より
u64
での実装
の方が高速だったので、とりあえずそうしている。BitSet<u128>
のようにすると煩雑になりそう。
Implementations§
source§impl BitSet
impl BitSet
pub fn new(capacity: usize) -> Self
pub fn insert(&mut self, index: usize)
pub fn remove(&mut self, index: usize)
pub fn contains(&self, index: usize) -> bool
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn capacity(&self) -> usize
pub fn and_assign(&mut self, other: &Self)
pub fn or_assign(&mut self, other: &Self)
pub fn ior_assign(&mut self, other: &Self)
pub fn xor_assign(&mut self, other: &Self)
pub fn sub_assign(&mut self, other: &Self)
pub fn not_assign(&mut self)
pub fn shl_assign(&mut self, shl: usize)
pub fn shr_assign(&mut self, shr: usize)
pub fn and(&self, other: &Self) -> Self
pub fn or(&self, other: &Self) -> Self
pub fn ior(&self, other: &Self) -> Self
pub fn xor(&self, other: &Self) -> Self
pub fn sub(&self, other: &Self) -> Self
pub fn not(&self) -> Self
pub fn shl(&self, shl: usize) -> Self
pub fn shr(&self, shr: usize) -> Self
pub fn reserve_exact(&mut self, new_capacity: usize)
pub fn reserve(&mut self, at_least: usize)
pub fn autofix(&mut self, enable: bool)
pub fn words(&self, range: impl RangeBounds<usize>) -> Words<'_> ⓘ
pub fn indices(&self, range: impl RangeBounds<usize>) -> Indices<'_> ⓘ
pub fn find_first(&self, range: impl RangeBounds<usize>) -> Option<usize>
pub fn find_last(&self, range: impl RangeBounds<usize>) -> Option<usize>
source§impl BitSet
impl BitSet
pub fn shl_and_self_assign(&mut self, x: usize)
pub fn shl_ior_self_assign(&mut self, x: usize)
pub fn shl_xor_self_assign(&mut self, x: usize)
pub fn shr_and_self_assign(&mut self, x: usize)
pub fn shr_ior_self_assign(&mut self, x: usize)
pub fn shr_xor_self_assign(&mut self, x: usize)
pub fn shl_and_assign(&mut self, x: usize, other: &Self)
pub fn shl_ior_assign(&mut self, x: usize, other: &Self)
pub fn shl_xor_assign(&mut self, x: usize, other: &Self)
pub fn shr_and_assign(&mut self, x: usize, other: &Self)
pub fn shr_ior_assign(&mut self, x: usize, other: &Self)
pub fn shr_xor_assign(&mut self, x: usize, other: &Self)
pub fn shl_or_self_assign(&mut self, x: usize)
pub fn shr_or_self_assign(&mut self, x: usize)
pub fn shl_or_assign(&mut self, x: usize, other: &Self)
pub fn shr_or_assign(&mut self, x: usize, other: &Self)
pub fn shl_and(&self, sh: usize, other: &Self) -> Self
pub fn shl_and_self(&self, sh: usize) -> Self
pub fn shl_ior(&self, sh: usize, other: &Self) -> Self
pub fn shl_ior_self(&self, sh: usize) -> Self
pub fn shl_xor(&self, sh: usize, other: &Self) -> Self
pub fn shl_xor_self(&self, sh: usize) -> Self
pub fn shl_sub(&self, sh: usize, other: &Self) -> Self
pub fn shl_sub_self(&self, sh: usize) -> Self
pub fn shr_and(&self, sh: usize, other: &Self) -> Self
pub fn shr_and_self(&self, sh: usize) -> Self
pub fn shr_ior(&self, sh: usize, other: &Self) -> Self
pub fn shr_ior_self(&self, sh: usize) -> Self
pub fn shr_xor(&self, sh: usize, other: &Self) -> Self
pub fn shr_xor_self(&self, sh: usize) -> Self
pub fn shr_sub(&self, sh: usize, other: &Self) -> Self
pub fn shr_sub_self(&self, sh: usize) -> Self
pub fn shl_or(&self, sh: usize, other: &Self) -> Self
pub fn shl_or_self(&self, sh: usize) -> Self
pub fn shr_or(&self, sh: usize, other: &Self) -> Self
pub fn shr_or_self(&self, sh: usize) -> Self
pub fn shl_sub_assign(&mut self, shl: usize, other: &Self)
pub fn shl_sub_self_assign(&mut self, shl: usize)
pub fn shr_sub_assign(&mut self, shr: usize, other: &Self)
pub fn shr_sub_self_assign(&mut self, shr: usize)
pub fn shl_op_assign( &mut self, shl: usize, other: &Self, f: impl Fn(u64, u64) -> u64 )
pub fn shl_op_self_assign(&mut self, shl: usize, f: impl Fn(u64, u64) -> u64)
pub fn shr_op_assign( &mut self, shr: usize, other: &Self, f: impl Fn(u64, u64) -> u64 )
pub fn shr_op_self_assign(&mut self, shr: usize, f: impl Fn(u64, u64) -> u64)
pub fn shl_op( &self, sh: usize, other: &Self, f: impl Fn(u64, u64) -> u64 ) -> Self
pub fn shl_op_self(&self, sh: usize, f: impl Fn(u64, u64) -> u64) -> Self
pub fn shr_op( &self, sh: usize, other: &Self, f: impl Fn(u64, u64) -> u64 ) -> Self
pub fn shr_op_self(&self, sh: usize, f: impl Fn(u64, u64) -> u64) -> Self
Trait Implementations§
source§impl BitAndAssign<&BitSet> for BitSet
impl BitAndAssign<&BitSet> for BitSet
source§fn bitand_assign(&mut self, other: &Self)
fn bitand_assign(&mut self, other: &Self)
Performs the
&=
operation. Read moresource§impl BitAndAssign<BitSet> for BitSet
impl BitAndAssign<BitSet> for BitSet
source§fn bitand_assign(&mut self, other: Self)
fn bitand_assign(&mut self, other: Self)
Performs the
&=
operation. Read moresource§impl BitOrAssign<&BitSet> for BitSet
impl BitOrAssign<&BitSet> for BitSet
source§fn bitor_assign(&mut self, other: &Self)
fn bitor_assign(&mut self, other: &Self)
Performs the
|=
operation. Read moresource§impl BitOrAssign<BitSet> for BitSet
impl BitOrAssign<BitSet> for BitSet
source§fn bitor_assign(&mut self, other: Self)
fn bitor_assign(&mut self, other: Self)
Performs the
|=
operation. Read moresource§impl BitXorAssign<&BitSet> for BitSet
impl BitXorAssign<&BitSet> for BitSet
source§fn bitxor_assign(&mut self, other: &Self)
fn bitxor_assign(&mut self, other: &Self)
Performs the
^=
operation. Read moresource§impl BitXorAssign<BitSet> for BitSet
impl BitXorAssign<BitSet> for BitSet
source§fn bitxor_assign(&mut self, other: Self)
fn bitxor_assign(&mut self, other: Self)
Performs the
^=
operation. Read moresource§impl Extend<usize> for BitSet
impl Extend<usize> for BitSet
source§fn extend<T>(&mut self, iter: T)where
T: IntoIterator<Item = usize>,
fn extend<T>(&mut self, iter: T)where T: IntoIterator<Item = usize>,
Extends a collection with the contents of an iterator. Read more
source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
🔬This is a nightly-only experimental API. (
extend_one
)Extends a collection with exactly one element.
source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
🔬This is a nightly-only experimental API. (
extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more
source§impl FromIterator<usize> for BitSet
impl FromIterator<usize> for BitSet
source§impl Ord for BitSet
impl Ord for BitSet
source§impl PartialEq<BitSet> for BitSet
impl PartialEq<BitSet> for BitSet
source§impl PartialOrd<BitSet> for BitSet
impl PartialOrd<BitSet> for BitSet
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresource§impl ShlAssign<usize> for BitSet
impl ShlAssign<usize> for BitSet
source§fn shl_assign(&mut self, sh: usize)
fn shl_assign(&mut self, sh: usize)
Performs the
<<=
operation. Read moresource§impl ShrAssign<usize> for BitSet
impl ShrAssign<usize> for BitSet
source§fn shr_assign(&mut self, sh: usize)
fn shr_assign(&mut self, sh: usize)
Performs the
>>=
operation. Read moresource§impl SubAssign<&BitSet> for BitSet
impl SubAssign<&BitSet> for BitSet
source§fn sub_assign(&mut self, other: &Self)
fn sub_assign(&mut self, other: &Self)
Performs the
-=
operation. Read moresource§impl SubAssign<BitSet> for BitSet
impl SubAssign<BitSet> for BitSet
source§fn sub_assign(&mut self, other: Self)
fn sub_assign(&mut self, other: Self)
Performs the
-=
operation. Read moreimpl Eq for BitSet
impl StructuralEq for BitSet
Auto Trait Implementations§
impl RefUnwindSafe for BitSet
impl Send for BitSet
impl Sync for BitSet
impl Unpin for BitSet
impl UnwindSafe for BitSet
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