uint_bits
BitvVariant
Op
BigBitv
Bitv
SmallBitv
for SmallBitv
for BigBitv
for Bitv
for Bitv
of ops::Index<uint, bool> for Bitv
BigBitv
Bitv
SmallBitv
big_mask
- a mask that has a 1 for each defined bit in the nth element of a big_bitv, assuming n bits.from_bools
- Transform a [bool] into a bitv by converting each bool into a bit.from_bytes
- Transform a byte-vector into a bitvfrom_fn
- Create a bitv of the specified length where the value at each index is f(index).land
lor
right
small_mask
- a mask that has a 1 for each defined bit in a small_bitv, assuming n bitsuint_bits
uint
BitvVariant
Big(~BigBitv)
Small(~SmallBitv)
Op
Union
Intersect
Assign
Difference
BigBitv
struct BigBitv {
mut storage: ~[mut uint],
}
Bitv
pub struct Bitv {
rep: BitvVariant,
nbits: uint,
}
SmallBitv
struct SmallBitv {
mut bits: u32,
}
SmallBitv
bits_op
fn bits_op(right_bits: u32, nbits: uint, f: fn&(u32, u32) -> u32) -> bool
union
fn union(s: & SmallBitv, nbits: uint) -> bool
intersect
fn intersect(s: & SmallBitv, nbits: uint) -> bool
become
fn become(s: & SmallBitv, nbits: uint) -> bool
difference
fn difference(s: & SmallBitv, nbits: uint) -> bool
get
fn get(i: uint) -> bool
set
fn set(i: uint, x: bool)
equals
fn equals(b: & SmallBitv, nbits: uint) -> bool
clear
fn clear()
set_all
fn set_all()
is_true
fn is_true(nbits: uint) -> bool
is_false
fn is_false(nbits: uint) -> bool
invert
fn invert()
BigBitv
process
fn process(b: & BigBitv, nbits: uint, op: fn&(uint, uint) -> uint) -> bool
each_storage
fn each_storage(op: fn&(v: & mut uint) -> bool)
invert
fn invert()
union
fn union(b: & BigBitv, nbits: uint) -> bool
intersect
fn intersect(b: & BigBitv, nbits: uint) -> bool
become
fn become(b: & BigBitv, nbits: uint) -> bool
difference
fn difference(b: & BigBitv, nbits: uint) -> bool
get
fn get(i: uint) -> bool
set
fn set(i: uint, x: bool)
equals
fn equals(b: & BigBitv, nbits: uint) -> bool
Bitv
die
fn die() -> !
do_op
fn do_op(op: Op, other: & Bitv) -> bool
Bitv
union
fn union(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.
intersect
fn intersect(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.
assign
fn assign(v: & Bitv) -> bool
Assigns the value of v1
to self
Both bitvectors must be the same length. Returns true
if self
was changed
clone
fn clone() -> ~Bitv
Makes a copy of a bitvector
get
fn get(i: uint) -> bool
Retrieve the value at index i
set
fn set(i: uint, x: bool)
Set the value of a bit at a given index
i
must be less than the length of the bitvector.
equal
fn equal(v1: & Bitv) -> bool
Compares two bitvectors
Both bitvectors must be the same length. Returns true
if both bitvectors contain identical elements.
clear
fn clear()
Set all bits to 0
set_all
fn set_all()
Set all bits to 1
invert
fn invert()
Invert all bits
difference
fn difference(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.
is_true
fn is_true() -> bool
Returns true if all bits are 1
each
fn each(f: fn&(bool) -> bool)
is_false
fn is_false() -> bool
Returns true if all bits are 0
init_to_vec
fn init_to_vec(i: uint) -> uint
to_vec
fn to_vec() -> ~[uint]
Converts self
to a vector of uint with the same length.
Each uint in the resulting vector has either value 0u or 1u.
to_bytes
fn to_bytes() -> ~[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
to_bools
fn to_bools() -> ~[bool]
Transform self into a [bool] by turning each bit into a bool
to_str
fn to_str() -> ~str
Converts self
to a string.
The resulting string has the same length as self
, and each character is either '0' or '1'.
eq_vec
fn eq_vec(v: ~[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
ones
fn ones(f: fn&(uint) -> bool)
ops::Index<uint, bool>
for Bitv
index
fn index(i: uint) -> bool
BigBitv
fn BigBitv(storage: ~[mut uint]) -> BigBitv
Bitv
fn Bitv(nbits: uint, init: bool) -> Bitv
SmallBitv
fn SmallBitv(bits: u32) -> SmallBitv
big_mask
fn big_mask(nbits: uint, elem: uint) -> uint
a mask that has a 1 for each defined bit in the nth element of a big_bitv, assuming n bits.
from_bools
fn from_bools(bools: & [bool]) -> Bitv
Transform a [bool] into a bitv by converting each bool into a bit.
from_bytes
fn from_bytes(bytes: & [u8]) -> Bitv
Transform a byte-vector into a bitv. Each byte becomes 8 bits, with the most significant bits of each byte coming first. Each bit becomes true if equal to 1 or false if equal to 0.
from_fn
fn from_fn(len: uint, f: fn&(index: uint) -> bool) -> Bitv
Create a bitv of the specified length where the value at each index is f(index).
land
fn land(w0: uint, w1: uint) -> uint
lor
fn lor(w0: uint, w1: uint) -> uint
right
fn right(_w0: uint, w1: uint) -> uint
small_mask
fn small_mask(nbits: uint) -> u32
a mask that has a 1 for each defined bit in a small_bitv, assuming n bits