Type bitv

type bitv = @{storage: ~[mut uint], nbits: uint,}

The bitvector type

Function 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

Function bitv

fn bitv(nbits: uint, init: bool) -> bitv

Constructs a bitvector

Arguments

Function clear

fn clear(v: bitv)

Set all bits to 0

Function clone

fn clone(v: bitv) -> bitv

Makes a copy of a bitvector

Function 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.

Function 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

Function 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.

Function get

pure fn get(v: bitv, i: uint) -> bool

Retrieve the value at index i

Function 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.

Function invert

fn invert(v: bitv)

Invert all bits

Function is_false

fn is_false(v: bitv) -> bool

Returns true if all bits are 0

Function is_true

fn is_true(v: bitv) -> bool

Returns true if all bits are 1

Function 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.

Function set_all

fn set_all(v: bitv)

Set all bits to 1

Function 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'.

Function 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.

Function union

fn union(v0: bitv, v1: bitv) -> bool