Trait BitSet

Source
pub trait BitSet {
    // Required methods
    fn set_bit(&mut self, position: usize, value: bool);
    fn get_bit(&self, position: usize) -> bool;
    fn get_weight(&self) -> u32;
    fn reset(&mut self);
    fn to_string(self) -> String;
}
Expand description

Trait to define the basic functions of a BitSet

Required Methods§

Source

fn set_bit(&mut self, position: usize, value: bool)

Sets the value of the bit at position position to value

Source

fn get_bit(&self, position: usize) -> bool

Gets the value of the bit at position position

Source

fn get_weight(&self) -> u32

Returns the bitset’s Hamming weight

Source

fn reset(&mut self)

Resets the bitset

Source

fn to_string(self) -> String

Produces a string representation of the bitset (little endian), aligned with 64 bits and with leading zeroes

Implementors§

Source§

impl BitSet for DenseBitSet

This is a compact implementation of the BitSet trait over a 64-bit word (which is the native word size for many architectures), allowing for efficient operations and compact memory usage.

Modifiers and accessors are boundary checked to ensure that operations remain within that 64 bit range.

Note: The BitSet trait must be in scope in order to use methods from this trait.

Source§

impl BitSet for DenseBitSetExtended

This is an extended implementation of the BitSet trait. It dynamically resizes the bitset as necessary to accomodate growing or shrinking operations (e.g. left shifts) and is only limited by available memory. In practice however, we (arbitrarily) limited allocation to 64000 bits.

Note: The BitSet trait must be in scope in order to use methods from this trait.

Note: The Copy trait cannot be implemented for DenseBitSetExtended (for the same reasons avec Vec).