Struct bitsets::DenseBitSet[][src]

pub struct DenseBitSet { /* fields omitted */ }

A dense bit set implemented over std::Vec<usize>

Methods

impl DenseBitSet
[src]

Creates a DenseBitSet that can contain at least num_bits bits. This will be rounded to the nearest word size that can accomodate num_bits bits.

Examples

Basic usage:

use bitsets::DenseBitSet;
 
let mut bs = DenseBitSet::with_capacity(128);
 
bs.set(1);
bs.set(2);
bs.set(3);
 
assert!(bs.test(1));
assert!(bs.test(2));
assert!(bs.test(3));

Creates a DenseBitSet that can contain at least num_bits bits. Each word of the underlying storage is initialized to initial_state.

Examples

use bitsets::DenseBitSet;
 
// 11111111111111111111111111111111111111111111111111111111
let bs1 = DenseBitSet::with_capacity_and_state(64, std::usize::MAX);

// 00000000000000000000000000000000000000000000000000000000
let bs2 = DenseBitSet::with_capacity_and_state(64, 0);

creates a single-word sized DenseBitSet initialized to bit_pattern.

Examples

use bitsets::DenseBitSet;
let bs = DenseBitSet::from_bits(0b0101010101010101);
 
assert!(bs.test(0));
assert!(!bs.test(1));

Creates a DenseBitSet using the given Vec as the underlying bits.

Tests whether the ith bit is set Returns true if is set, else false

Examples

use bitsets::DenseBitSet;
 
let bs = DenseBitSet::with_capacity(64);
assert!(!bs.test(16));

Sets the ith bit. Returns true if bit was not set previously

Examples

use bitsets::DenseBitSet;
 
let mut bs = DenseBitSet::with_capacity(64);
 
let is_present = bs.test(32);
assert!(!is_present);
 
let first_time_set = bs.set(32);
assert!(first_time_set);
 
let is_present = bs.test(32);
assert!(is_present);

flips the value of the ith bit

Examples

use bitsets::DenseBitSet;
 
let mut bs = DenseBitSet::with_capacity(64);
 
assert!(!bs.test(16));
assert!(!bs.test(24));
bs.set(46);
assert!(bs.test(46));
 
bs.flip(14);
bs.flip(24);
bs.flip(46);
 
assert!(bs.test(14));
assert!(bs.test(24));
assert!(!bs.test(46));
 

In-place bitwise-not

In-place bitwise-and with other

In-place bitwise-or with other

In-place bitwise-xor with other

returns the number of elements in the underlying Vec

returns the number of bits this set can accommodate

Trait Implementations

impl Clone for DenseBitSet
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl Eq for DenseBitSet
[src]

impl PartialEq for DenseBitSet
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl Debug for DenseBitSet
[src]

Formats the value using the given formatter. Read more

Auto Trait Implementations

impl Send for DenseBitSet

impl Sync for DenseBitSet