Struct bitsets::DenseBitSet [−][src]
pub struct DenseBitSet { /* fields omitted */ }
A dense bit set implemented over std::Vec<usize>
Methods
impl DenseBitSet
[src]
impl DenseBitSet
pub fn with_capacity(num_bits: usize) -> DenseBitSet
[src]
pub fn with_capacity(num_bits: usize) -> DenseBitSet
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));
pub fn with_capacity_and_state(
num_bits: usize,
initial_state: usize
) -> DenseBitSet
[src]
pub fn with_capacity_and_state(
num_bits: usize,
initial_state: usize
) -> DenseBitSet
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);
pub fn from_bits(bit_pattern: usize) -> DenseBitSet
[src]
pub fn from_bits(bit_pattern: usize) -> DenseBitSet
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));
pub fn from_vec(v: Vec<usize>) -> DenseBitSet
[src]
pub fn from_vec(v: Vec<usize>) -> DenseBitSet
Creates a DenseBitSet using the given Vec as the underlying bits.
pub fn test(&self, i: usize) -> bool
[src]
pub fn test(&self, i: usize) -> bool
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));
pub fn set(&mut self, i: usize) -> bool
[src]
pub fn set(&mut self, i: usize) -> bool
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);
pub fn flip(&mut self, i: usize)
[src]
pub fn flip(&mut self, i: usize)
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));
pub fn inplace_not(&mut self)
[src]
pub fn inplace_not(&mut self)
In-place bitwise-not
pub fn inplace_and(&mut self, other: &DenseBitSet)
[src]
pub fn inplace_and(&mut self, other: &DenseBitSet)
In-place bitwise-and with other
pub fn inplace_or(&mut self, other: &DenseBitSet)
[src]
pub fn inplace_or(&mut self, other: &DenseBitSet)
In-place bitwise-or with other
pub fn inplace_xor(&mut self, other: &DenseBitSet)
[src]
pub fn inplace_xor(&mut self, other: &DenseBitSet)
In-place bitwise-xor with other
pub fn and(&self, other: &DenseBitSet) -> DenseBitSet
[src]
pub fn and(&self, other: &DenseBitSet) -> DenseBitSet
pub fn or(&self, other: &DenseBitSet) -> DenseBitSet
[src]
pub fn or(&self, other: &DenseBitSet) -> DenseBitSet
pub fn xor(&self, other: &DenseBitSet) -> DenseBitSet
[src]
pub fn xor(&self, other: &DenseBitSet) -> DenseBitSet
pub fn words(&self) -> usize
[src]
pub fn words(&self) -> usize
returns the number of elements in the underlying Vec
pub fn len(&self) -> usize
[src]
pub fn len(&self) -> usize
returns the number of bits this set can accommodate
Trait Implementations
impl Clone for DenseBitSet
[src]
impl Clone for DenseBitSet
fn clone(&self) -> DenseBitSet
[src]
fn clone(&self) -> DenseBitSet
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl Eq for DenseBitSet
[src]
impl Eq for DenseBitSet
impl PartialEq for DenseBitSet
[src]
impl PartialEq for DenseBitSet
fn eq(&self, other: &DenseBitSet) -> bool
[src]
fn eq(&self, other: &DenseBitSet) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &DenseBitSet) -> bool
[src]
fn ne(&self, other: &DenseBitSet) -> bool
This method tests for !=
.
impl Debug for DenseBitSet
[src]
impl Debug for DenseBitSet
Auto Trait Implementations
impl Send for DenseBitSet
impl Send for DenseBitSet
impl Sync for DenseBitSet
impl Sync for DenseBitSet