pub struct DenseBitSetExtended { /* fields omitted */ }Provides a dense BitSet implementation (only limited by available memory)
Internally, a Vec<u64> data structure is used to store information.
This structure implements BitSet, Clone, Default, Debug, Hash, PartialEq, Eq and bit operations.
Returns a new empty DenseBitsetExtended
let bs = DenseBitSetExtended::new();
Returns an empty DenseBitsetExtended with pre-allocated memory of size bits.
This is useful to avoid additional allocations is situations where the bitset's
space requirements are known in advance.
let mut bs = DenseBitSetExtended::with_capacity(128);
bs.set_bit(127, true);
This function will not accept size parameters beyond 64000 bits.
Returns a DenseBitSetExtended extending a given DenseBitSet.
let dbs = DenseBitSet::from_integer(0b111000111);
let dbse = DenseBitSetExtended::from_dense_bitset(dbs);
println!("{}", dbse.to_string())
Returns true if and only if all bits are set to true
Returns true if at least one bit is set to true
Returns true if all the bits are set to false
Returns the size (in bits) of the bitset
Returns an integer representation of the bitsting starting at the given position with given length (little endian convention).
Note: this method can extract up to 64 bits into an u64. For larger extractions, use subset instead.
let dbs = DenseBitSet::from_integer(0b111000111);
let dbse = DenseBitSetExtended::from_dense_bitset(dbs);
println!("{}", dbse.extract_u64(2, 4));
The function panics if length is zero
let panic_me = dbse.extract_u64(3, 0);
Returns a DenseBitSetExtended of given length whose bits are extracted from the given position.
let dbs = DenseBitSet::from_integer(0b111000111);
let dbse = DenseBitSetExtended::from_dense_bitset(dbs);
println!("{}", dbse.subset(2, 4).to_string());
Inserts the first length bits of other at the given position in the current structure.
let mut bs = DenseBitSetExtended::new();
let bs2 =
DenseBitSetExtended::from_dense_bitset(DenseBitSet::from_integer(0b1011011101111));
bs.insert(&bs2, 60, 13);
Inserts a length-bit integer as a bitset at the given position.
let mut bs = DenseBitSetExtended::new();
bs.insert_u64(0b1011011101111, 50, 64);
Returns a bit-reversed bitset.
let val = 66612301234;
let dbs = DenseBitSet::from_integer(val);
let ext_dbs = DenseBitSetExtended::from_dense_bitset(dbs);
println!("{}", dbs.to_string());
println!("{}", ext_dbs.reverse().to_string());
Returns a left rotation of the bitset by shift bits.
Note: The bitset is extended by shift bits by this operation.
Returns a right rotation of the bitset by shift bits.
Constructs a DenseBitSetExtended from a provided String.
let bs2 = DenseBitSetExtended::from_string(String::from("f8d5215a52b57ea0aeb294af576a0aeb"), 16);
This function expects a radix between 2 and 32 included, and will otherwise panic.
This function will also panic if incorrect characters are provided.
Returns the position of the first set bit (little endian convention)
let dbs = DenseBitSetExtended::from_dense_bitset( DenseBitSet::from_integer(256) ) << 12;
println!("{}", dbs.first_set());
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).
Sets the bit at index position to value.
Get the bit at index position.
Returns the bitset's Hamming weight (in other words, the number of bits set to true).
This resets the bitset to its empty state.
Returns a representation of the bitset as a String.
Returns the "default value" for a type. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=.
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Feeds this value into the given [Hasher]. Read more
Feeds a slice of this type into the given [Hasher]. Read more
The resulting type after applying the ! operator.
Performs the unary ! operation.
The resulting type after applying the & operator.
Performs the & operation.
The resulting type after applying the | operator.
Performs the | operation.
The resulting type after applying the ^ operator.
Performs the ^ operation.
The resulting type after applying the << operator.
Performs the << operation.
The resulting type after applying the >> operator.
Performs the >> operation.
Performs the &= operation.
Performs the |= operation.
Performs the ^= operation.
Performs the <<= operation.
Performs the >>= operation.
Creates owned data from borrowed data, usually by cloning. Read more
🔬 This is a nightly-only experimental API. (toowned_clone_into)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
🔬 This is a nightly-only experimental API. (try_from)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from)
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
🔬 This is a nightly-only experimental API. (try_from)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from)
🔬 This is a nightly-only experimental API. (get_type_id)
this method will likely be replaced by an associated static