BitSet

Struct BitSet 

Source
pub struct BitSet { /* private fields */ }

Implementations§

Source§

impl BitSet

Source

pub fn new(size: usize) -> Self

Examples found in repository?
crates/competitive/src/data_structure/bitset.rs (line 143)
142    fn from_iter<T: IntoIterator<Item = bool>>(iter: T) -> Self {
143        let mut set = BitSet::new(0);
144        set.extend(iter);
145        set
146    }
Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn ones(size: usize) -> Self

Source

pub fn get(&self, i: usize) -> bool

Examples found in repository?
crates/competitive/src/algorithm/automata_learning.rs (line 384)
367    pub fn construct_dfa(&mut self) -> DeterministicFiniteAutomaton {
368        let sigma = self.automaton.sigma();
369        let mut dfa = DeterministicFiniteAutomaton {
370            states: vec![],
371            initial_state: 0,
372        };
373        let mut i_prefix = 0;
374        while i_prefix < self.prefixes.len() {
375            let mut delta = vec![];
376            for x in 0..sigma {
377                let prefix: Vec<usize> =
378                    self.prefixes[i_prefix].iter().cloned().chain([x]).collect();
379                let index = self.add_prefix(prefix);
380                delta.push(index);
381            }
382            dfa.states.push(DfaState {
383                delta,
384                accept: self.table[i_prefix].get(0),
385            });
386            i_prefix += 1;
387        }
388        dfa
389    }
Source

pub fn set(&mut self, i: usize, b: bool)

Source

pub fn count_ones(&self) -> u64

Examples found in repository?
crates/competitive/src/data_structure/bitset.rs (line 56)
55    pub fn count_zeros(&self) -> u64 {
56        self.size as u64 - self.count_ones()
57    }
Source

pub fn count_zeros(&self) -> u64

Source

pub fn push(&mut self, b: bool)

Examples found in repository?
crates/competitive/src/algorithm/automata_learning.rs (lines 356-359)
351    fn add_suffix(&mut self, suffix: Vec<usize>) {
352        if self.suffixes.contains(&suffix) {
353            return;
354        }
355        for (prefix, table) in self.prefixes.iter_mut().zip(&mut self.table) {
356            table.push(
357                self.automaton
358                    .behavior(prefix.iter().cloned().chain(suffix.iter().cloned())),
359            );
360        }
361        self.suffixes.push(suffix);
362        self.row_map.clear();
363        for (i_prefix, row) in self.table.iter().enumerate() {
364            self.row_map.insert(row.clone(), i_prefix);
365        }
366    }
Source

pub fn shl_bitor_assign(&mut self, rhs: usize)

Source

pub fn shr_bitor_assign(&mut self, rhs: usize)

Trait Implementations§

Source§

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

Source§

type Output = BitSet

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: &'b BitSet) -> Self::Output

Performs the & operation. Read more
Source§

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

Source§

type Output = BitSet

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: &'a Self) -> Self::Output

Performs the & operation. Read more
Source§

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

Source§

fn bitand_assign(&mut self, rhs: &'a Self)

Performs the &= operation. Read more
Source§

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

Source§

type Output = BitSet

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: &'b BitSet) -> Self::Output

Performs the | operation. Read more
Source§

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

Source§

type Output = BitSet

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: &'a Self) -> Self::Output

Performs the | operation. Read more
Source§

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

Source§

fn bitor_assign(&mut self, rhs: &'a Self)

Performs the |= operation. Read more
Source§

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

Source§

type Output = BitSet

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: &'b BitSet) -> Self::Output

Performs the ^ operation. Read more
Source§

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

Source§

type Output = BitSet

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: &'a Self) -> Self::Output

Performs the ^ operation. Read more
Source§

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

Source§

fn bitxor_assign(&mut self, rhs: &'a Self)

Performs the ^= operation. Read more
Source§

impl Clone for BitSet

Source§

fn clone(&self) -> BitSet

Returns a duplicate 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<bool> for BitSet

Source§

fn extend<T: IntoIterator<Item = bool>>(&mut self, iter: T)

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<bool> for BitSet

Source§

fn from_iter<T: IntoIterator<Item = bool>>(iter: T) -> Self

Creates a value from an iterator. Read more
Source§

impl Hash for BitSet

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Not for &BitSet

Source§

type Output = BitSet

The resulting type after applying the ! operator.
Source§

fn not(self) -> Self::Output

Performs the unary ! operation. Read more
Source§

impl Not for BitSet

Source§

type Output = BitSet

The resulting type after applying the ! operator.
Source§

fn not(self) -> Self::Output

Performs the unary ! operation. Read more
Source§

impl Ord for BitSet

Source§

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

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

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

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

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

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

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

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

impl PartialEq for BitSet

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · 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 PartialOrd for BitSet

Source§

fn partial_cmp(&self, other: &BitSet) -> 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

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

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

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Shl<usize> for BitSet

Source§

type Output = BitSet

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

fn shl(self, rhs: usize) -> Self::Output

Performs the << operation. Read more
Source§

impl ShlAssign<usize> for BitSet

Source§

fn shl_assign(&mut self, rhs: usize)

Performs the <<= operation. Read more
Source§

impl Shr<usize> for BitSet

Source§

type Output = BitSet

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

fn shr(self, rhs: usize) -> Self::Output

Performs the >> operation. Read more
Source§

impl ShrAssign<usize> for BitSet

Source§

fn shr_assign(&mut self, rhs: usize)

Performs the >>= operation. Read more
Source§

impl Eq for BitSet

Source§

impl StructuralPartialEq for BitSet

Auto Trait Implementations§

§

impl Freeze for BitSet

§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> AsTotalOrd for T
where T: PartialOrd,

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> PartialOrdExt for T
where T: PartialOrd,

Source§

fn chmin(&mut self, other: T)

Source§

fn chmax(&mut self, other: T)

Source§

fn minmax(self, other: T) -> (T, T)

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.