Struct nekolib::ds::bit_set::BitSet

source ·
pub struct BitSet { /* private fields */ }
Expand description

Bit set。

Implementation notes

& | ^ について、左辺の capacity を持つ新たな BitSet を返すため、可換でない。 可換にすることにすると、 x = x | yx |= y の整合性を取りたくなり、|= の操作でも capacity を変化させるのが妥当になるが、あまりうれしくなさそう?

capacity は暗黙に変わらないような設計にしているが、eq() などでは capacity は無視するべき? 立っているビットが同じかを比較するときに eq() で済むのがうれしいか、cmp().is_eq() にするか? そこを短くするために capacity の比較を別でやる必要がある方がつらいか?

u128 での実装 より u64 での実装 の方が高速だったので、とりあえずそうしている。BitSet<u128> のようにすると煩雑になりそう。

Implementations§

source§

impl BitSet

source

pub fn new(capacity: usize) -> Self

source

pub fn insert(&mut self, index: usize)

source

pub fn remove(&mut self, index: usize)

source

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

source

pub fn len(&self) -> usize

source

pub fn is_empty(&self) -> bool

source

pub fn capacity(&self) -> usize

source

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

source

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

source

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

source

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

source

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

source

pub fn not_assign(&mut self)

source

pub fn shl_assign(&mut self, shl: usize)

source

pub fn shr_assign(&mut self, shr: usize)

source

pub fn and(&self, other: &Self) -> Self

source

pub fn or(&self, other: &Self) -> Self

source

pub fn ior(&self, other: &Self) -> Self

source

pub fn xor(&self, other: &Self) -> Self

source

pub fn sub(&self, other: &Self) -> Self

source

pub fn not(&self) -> Self

source

pub fn shl(&self, shl: usize) -> Self

source

pub fn shr(&self, shr: usize) -> Self

source

pub fn reserve_exact(&mut self, new_capacity: usize)

source

pub fn reserve(&mut self, at_least: usize)

source

pub fn autofix(&mut self, enable: bool)

source

pub fn words(&self, range: impl RangeBounds<usize>) -> Words<'_>

source

pub fn indices(&self, range: impl RangeBounds<usize>) -> Indices<'_>

source

pub fn find_first(&self, range: impl RangeBounds<usize>) -> Option<usize>

source

pub fn find_last(&self, range: impl RangeBounds<usize>) -> Option<usize>

source§

impl BitSet

source

pub fn shl_and_self_assign(&mut self, x: usize)

source

pub fn shl_ior_self_assign(&mut self, x: usize)

source

pub fn shl_xor_self_assign(&mut self, x: usize)

source

pub fn shr_and_self_assign(&mut self, x: usize)

source

pub fn shr_ior_self_assign(&mut self, x: usize)

source

pub fn shr_xor_self_assign(&mut self, x: usize)

source

pub fn shl_and_assign(&mut self, x: usize, other: &Self)

source

pub fn shl_ior_assign(&mut self, x: usize, other: &Self)

source

pub fn shl_xor_assign(&mut self, x: usize, other: &Self)

source

pub fn shr_and_assign(&mut self, x: usize, other: &Self)

source

pub fn shr_ior_assign(&mut self, x: usize, other: &Self)

source

pub fn shr_xor_assign(&mut self, x: usize, other: &Self)

source

pub fn shl_or_self_assign(&mut self, x: usize)

source

pub fn shr_or_self_assign(&mut self, x: usize)

source

pub fn shl_or_assign(&mut self, x: usize, other: &Self)

source

pub fn shr_or_assign(&mut self, x: usize, other: &Self)

source

pub fn shl_and(&self, sh: usize, other: &Self) -> Self

source

pub fn shl_and_self(&self, sh: usize) -> Self

source

pub fn shl_ior(&self, sh: usize, other: &Self) -> Self

source

pub fn shl_ior_self(&self, sh: usize) -> Self

source

pub fn shl_xor(&self, sh: usize, other: &Self) -> Self

source

pub fn shl_xor_self(&self, sh: usize) -> Self

source

pub fn shl_sub(&self, sh: usize, other: &Self) -> Self

source

pub fn shl_sub_self(&self, sh: usize) -> Self

source

pub fn shr_and(&self, sh: usize, other: &Self) -> Self

source

pub fn shr_and_self(&self, sh: usize) -> Self

source

pub fn shr_ior(&self, sh: usize, other: &Self) -> Self

source

pub fn shr_ior_self(&self, sh: usize) -> Self

source

pub fn shr_xor(&self, sh: usize, other: &Self) -> Self

source

pub fn shr_xor_self(&self, sh: usize) -> Self

source

pub fn shr_sub(&self, sh: usize, other: &Self) -> Self

source

pub fn shr_sub_self(&self, sh: usize) -> Self

source

pub fn shl_or(&self, sh: usize, other: &Self) -> Self

source

pub fn shl_or_self(&self, sh: usize) -> Self

source

pub fn shr_or(&self, sh: usize, other: &Self) -> Self

source

pub fn shr_or_self(&self, sh: usize) -> Self

source

pub fn shl_sub_assign(&mut self, shl: usize, other: &Self)

source

pub fn shl_sub_self_assign(&mut self, shl: usize)

source

pub fn shr_sub_assign(&mut self, shr: usize, other: &Self)

source

pub fn shr_sub_self_assign(&mut self, shr: usize)

source

pub fn shl_op_assign( &mut self, shl: usize, other: &Self, f: impl Fn(u64, u64) -> u64 )

source

pub fn shl_op_self_assign(&mut self, shl: usize, f: impl Fn(u64, u64) -> u64)

source

pub fn shr_op_assign( &mut self, shr: usize, other: &Self, f: impl Fn(u64, u64) -> u64 )

source

pub fn shr_op_self_assign(&mut self, shr: usize, f: impl Fn(u64, u64) -> u64)

source

pub fn shl_op( &self, sh: usize, other: &Self, f: impl Fn(u64, u64) -> u64 ) -> Self

source

pub fn shl_op_self(&self, sh: usize, f: impl Fn(u64, u64) -> u64) -> Self

source

pub fn shr_op( &self, sh: usize, other: &Self, f: impl Fn(u64, u64) -> u64 ) -> Self

source

pub fn shr_op_self(&self, sh: usize, f: impl Fn(u64, u64) -> u64) -> Self

Trait Implementations§

source§

impl Binary for BitSet

source§

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

Formats the value using the given formatter.
source§

impl<'a> BitAnd<&'a BitSet> for &'a BitSet

§

type Output = BitSet

The resulting type after applying the & operator.
source§

fn bitand(self, other: Self) -> BitSet

Performs the & operation. Read more
source§

impl BitAnd<&BitSet> for BitSet

§

type Output = BitSet

The resulting type after applying the & operator.
source§

fn bitand(self, other: &Self) -> Self

Performs the & operation. Read more
source§

impl<'a> BitAnd<BitSet> for &'a BitSet

§

type Output = BitSet

The resulting type after applying the & operator.
source§

fn bitand(self, other: BitSet) -> BitSet

Performs the & operation. Read more
source§

impl BitAnd<BitSet> for BitSet

§

type Output = BitSet

The resulting type after applying the & operator.
source§

fn bitand(self, other: Self) -> Self

Performs the & operation. Read more
source§

impl BitAndAssign<&BitSet> for BitSet

source§

fn bitand_assign(&mut self, other: &Self)

Performs the &= operation. Read more
source§

impl BitAndAssign<BitSet> for BitSet

source§

fn bitand_assign(&mut self, other: Self)

Performs the &= operation. Read more
source§

impl<'a> BitOr<&'a BitSet> for &'a BitSet

§

type Output = BitSet

The resulting type after applying the | operator.
source§

fn bitor(self, other: Self) -> BitSet

Performs the | operation. Read more
source§

impl BitOr<&BitSet> for BitSet

§

type Output = BitSet

The resulting type after applying the | operator.
source§

fn bitor(self, other: &Self) -> Self

Performs the | operation. Read more
source§

impl<'a> BitOr<BitSet> for &'a BitSet

§

type Output = BitSet

The resulting type after applying the | operator.
source§

fn bitor(self, other: BitSet) -> BitSet

Performs the | operation. Read more
source§

impl BitOr<BitSet> for BitSet

§

type Output = BitSet

The resulting type after applying the | operator.
source§

fn bitor(self, other: Self) -> Self

Performs the | operation. Read more
source§

impl BitOrAssign<&BitSet> for BitSet

source§

fn bitor_assign(&mut self, other: &Self)

Performs the |= operation. Read more
source§

impl BitOrAssign<BitSet> for BitSet

source§

fn bitor_assign(&mut self, other: Self)

Performs the |= operation. Read more
source§

impl<'a> BitXor<&'a BitSet> for &'a BitSet

§

type Output = BitSet

The resulting type after applying the ^ operator.
source§

fn bitxor(self, other: Self) -> BitSet

Performs the ^ operation. Read more
source§

impl BitXor<&BitSet> for BitSet

§

type Output = BitSet

The resulting type after applying the ^ operator.
source§

fn bitxor(self, other: &Self) -> Self

Performs the ^ operation. Read more
source§

impl<'a> BitXor<BitSet> for &'a BitSet

§

type Output = BitSet

The resulting type after applying the ^ operator.
source§

fn bitxor(self, other: BitSet) -> BitSet

Performs the ^ operation. Read more
source§

impl BitXor<BitSet> for BitSet

§

type Output = BitSet

The resulting type after applying the ^ operator.
source§

fn bitxor(self, other: Self) -> Self

Performs the ^ operation. Read more
source§

impl BitXorAssign<&BitSet> for BitSet

source§

fn bitxor_assign(&mut self, other: &Self)

Performs the ^= operation. Read more
source§

impl BitXorAssign<BitSet> for BitSet

source§

fn bitxor_assign(&mut self, other: Self)

Performs the ^= operation. Read more
source§

impl Clone for BitSet

source§

fn clone(&self) -> BitSet

Returns a copy 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 BitSet

source§

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

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

impl Default for BitSet

source§

fn default() -> BitSet

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

impl Extend<usize> for BitSet

source§

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)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
source§

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

source§

fn from_iter<T>(iter: T) -> Selfwhere T: IntoIterator<Item = usize>,

Creates a value from an iterator. Read more
source§

impl Not for &BitSet

§

type Output = BitSet

The resulting type after applying the ! operator.
source§

fn not(self) -> BitSet

Performs the unary ! operation. Read more
source§

impl Not for BitSet

§

type Output = BitSet

The resulting type after applying the ! operator.
source§

fn not(self) -> Self

Performs the unary ! operation. Read more
source§

impl Ord for BitSet

source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Selfwhere Self: Sized + PartialOrd<Self>,

Restrict a value to a certain interval. Read more
source§

impl PartialEq<BitSet> for BitSet

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd<BitSet> for BitSet

source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

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 more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Shl<usize> for &BitSet

§

type Output = BitSet

The resulting type after applying the << operator.
source§

fn shl(self, sh: usize) -> BitSet

Performs the << operation. Read more
source§

impl Shl<usize> for BitSet

§

type Output = BitSet

The resulting type after applying the << operator.
source§

fn shl(self, sh: usize) -> BitSet

Performs the << operation. Read more
source§

impl ShlAssign<usize> for BitSet

source§

fn shl_assign(&mut self, sh: usize)

Performs the <<= operation. Read more
source§

impl Shr<usize> for &BitSet

§

type Output = BitSet

The resulting type after applying the >> operator.
source§

fn shr(self, sh: usize) -> BitSet

Performs the >> operation. Read more
source§

impl Shr<usize> for BitSet

§

type Output = BitSet

The resulting type after applying the >> operator.
source§

fn shr(self, sh: usize) -> BitSet

Performs the >> operation. Read more
source§

impl ShrAssign<usize> for BitSet

source§

fn shr_assign(&mut self, sh: usize)

Performs the >>= operation. Read more
source§

impl<'a> Sub<&'a BitSet> for &'a BitSet

§

type Output = BitSet

The resulting type after applying the - operator.
source§

fn sub(self, other: Self) -> BitSet

Performs the - operation. Read more
source§

impl Sub<&BitSet> for BitSet

§

type Output = BitSet

The resulting type after applying the - operator.
source§

fn sub(self, other: &Self) -> Self

Performs the - operation. Read more
source§

impl<'a> Sub<BitSet> for &'a BitSet

§

type Output = BitSet

The resulting type after applying the - operator.
source§

fn sub(self, other: BitSet) -> BitSet

Performs the - operation. Read more
source§

impl Sub<BitSet> for BitSet

§

type Output = BitSet

The resulting type after applying the - operator.
source§

fn sub(self, other: Self) -> Self

Performs the - operation. Read more
source§

impl SubAssign<&BitSet> for BitSet

source§

fn sub_assign(&mut self, other: &Self)

Performs the -= operation. Read more
source§

impl SubAssign<BitSet> for BitSet

source§

fn sub_assign(&mut self, other: Self)

Performs the -= operation. Read more
source§

impl Eq for BitSet

source§

impl StructuralEq for BitSet

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. 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 Twhere 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> MakeMax for Twhere T: PartialOrd<T>,

source§

fn make_max(&mut self, other: Self) -> bool

source§

impl<T> MakeMin for Twhere T: PartialOrd<T>,

source§

fn make_min(&mut self, other: Self) -> bool

source§

impl<T> ToOwned for Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V