bitv
- The bitvector typeassign
- Assigns the value of v1
to v0
bitv
- Constructs a bitvectorclear
- Set all bits to 0clone
- Makes a copy of a bitvectordifference
- Calculate the difference between two bitvectorseq_vec
- Compare a bitvector to a vector of uintequal
- Compares two bitvectorsget
- Retrieve the value at index i
intersect
- Calculates the intersection of two bitvectorsinvert
- Invert all bitsis_false
- Returns true if all bits are 0is_true
- Returns true if all bits are 1set
- Set the value of a bit at a given indexset_all
- Set all bits to 1to_str
- Converts the bitvector to a string.to_vec
- Converts the bitvector to a vector of uint with the same length.union
bitv
type bitv = @{storage: ~[mut uint], nbits: uint,}
The bitvector type
assign
fn assign(v0: bitv, v1: bitv) -> bool
Assigns the value of v1
to v0
Both bitvectors must be the same length. Returns true
if v0
was changed
bitv
fn bitv(nbits: uint, init: bool) -> bitv
Constructs a bitvector
clear
fn clear(v: bitv)
Set all bits to 0
clone
fn clone(v: bitv) -> bitv
Makes a copy of a bitvector
difference
fn difference(v0: bitv, v1: 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.
eq_vec
fn eq_vec(v0: bitv, v1: ~[uint]) -> bool
Compare a bitvector to a vector of uint
The uint vector is expected to only contain the values 0u and 1u. Both the bitvector and vector must have the same length
equal
fn equal(v0: bitv, v1: bitv) -> bool
Compares two bitvectors
Both bitvectors must be the same length. Returns true
if both bitvectors contain identical elements.
get
pure fn get(v: bitv, i: uint) -> bool
Retrieve the value at index i
intersect
fn intersect(v0: bitv, v1: bitv) -> bool
Calculates the intersection of two bitvectors
Sets v0
to the intersection of v0
and v1
. Both bitvectors must be the same length. Returns 'true' if v0
was changed.
invert
fn invert(v: bitv)
Invert all bits
is_false
fn is_false(v: bitv) -> bool
Returns true if all bits are 0
is_true
fn is_true(v: bitv) -> bool
Returns true if all bits are 1
set
fn set(v: bitv, i: uint, x: bool)
Set the value of a bit at a given index
i
must be less than the length of the bitvector.
set_all
fn set_all(v: bitv)
Set all bits to 1
to_str
fn to_str(v: bitv) -> str
Converts the bitvector to a string.
The resulting string has the same length as the bitvector, and each character is either '0' or '1'.
to_vec
fn to_vec(v: bitv) -> ~[uint]
Converts the bitvector to a vector of uint with the same length.
Each uint in the resulting vector has either value 0u or 1u.
union
fn union(v0: bitv, v1: bitv) -> bool