pub struct Bitv { rep: BitvVariant, nbits: uint, }
The bitvector type
impl Bitv
fn new(nbits: uint, init: bool) -> Bitv
fn union(&mut self, v1: &Bitv) -> bool
Calculates the union of two bitvectors
Sets self
to the union of self
and v1
. Both bitvectors must be
the same length. Returns 'true' if self
changed.
fn intersect(&mut self, v1: &Bitv) -> bool
Calculates the intersection of two bitvectors
Sets self
to the intersection of self
and v1
. Both bitvectors
must be the same length. Returns 'true' if self
changed.
fn assign(&mut self, v: &Bitv) -> bool
Assigns the value of v1
to self
Both bitvectors must be the same length. Returns true
if self
was
changed
fn get(&self, i: uint) -> bool
Retrieve the value at index i
fn set(&mut self, i: uint, x: bool)
Set the value of a bit at a given index
i
must be less than the length of the bitvector.
fn equal(&self, v1: &Bitv) -> bool
Compares two bitvectors
Both bitvectors must be the same length. Returns true
if both
bitvectors contain identical elements.
fn clear(&mut self)
Set all bits to 0
fn set_all(&mut self)
Set all bits to 1
fn negate(&mut self)
Invert all bits
fn difference(&mut self, v: &Bitv) -> bool
Calculate the difference between two bitvectors
Sets each element of v0
to the value of that element minus the
element of v1
at the same index. Both bitvectors must be the same
length.
Returns true
if v0
was changed.
fn is_true(&self) -> bool
Returns true if all bits are 1
fn iter<'a>(&'a self) -> BitvIterator<'a>
fn rev_liter<'a>(&'a self) -> std::iter::Invert
fn is_false(&self) -> bool
Returns true if all bits are 0
fn init_to_vec(&self, i: uint) -> uint
fn to_vec(&self) -> ~[uint]
Converts self
to a vector of uint with the same length.
Each uint in the resulting vector has either value 0u or 1u.
fn to_bytes(&self) -> ~[u8]
Organise the bits into bytes, such that the first bit in the bitv becomes the high-order bit of the first byte. If the size of the bitv is not a multiple of 8 then trailing bits will be filled-in with false/0
fn to_bools(&self) -> ~[bool]
Transform self into a [bool] by turning each bit into a bool
fn to_str(&self) -> ~str
Converts self
to a string.
The resulting string has the same length as self
, and each
character is either '0' or '1'.
fn eq_vec(&self, v: &[bool]) -> bool
Compare a bitvector to a vector of bool.
Both the bitvector and vector must have the same length.
fn ones(&self, f: &fn(uint) -> bool) -> bool
impl std::clone::Clone for Bitv
fn clone(&self) -> Bitv
impl std::ops::Index for Bitv
fn index(&self, i: &uint) -> bool
Prefix searches with a type followed by a colon (e.g.
fn:
) to restrict the search to a given type.
Accepted types are: fn
, mod
,
struct
(or str
), enum
,
trait
, typedef
(or
tdef
).