Const uint_bits

uint

Enum BitvVariant

Variants

Enum Op

Variants

Struct BigBitv

struct BigBitv {
    mut storage: ~[mut uint],
}

Struct Bitv

pub struct Bitv {
        rep: BitvVariant,
        nbits: uint,
    }

Struct SmallBitv

struct SmallBitv {
    mut bits: u32,
}

Implementation for SmallBitv

Method bits_op

fn bits_op(right_bits: u32, nbits: uint, f: fn&(u32, u32) -> u32) -> bool

Method union

fn union(s: & SmallBitv, nbits: uint) -> bool

Method intersect

fn intersect(s: & SmallBitv, nbits: uint) -> bool

Method become

fn become(s: & SmallBitv, nbits: uint) -> bool

Method difference

fn difference(s: & SmallBitv, nbits: uint) -> bool

Method get

fn get(i: uint) -> bool

Method set

fn set(i: uint, x: bool)

Method equals

fn equals(b: & SmallBitv, nbits: uint) -> bool

Method clear

fn clear()

Method set_all

fn set_all()

Method is_true

fn is_true(nbits: uint) -> bool

Method is_false

fn is_false(nbits: uint) -> bool

Method invert

fn invert()

Implementation for BigBitv

Method process

fn process(b: & BigBitv, nbits: uint, op: fn&(uint, uint) -> uint) -> bool

Method each_storage

fn each_storage(op: fn&(v: & mut uint) -> bool)

Method invert

fn invert()

Method union

fn union(b: & BigBitv, nbits: uint) -> bool

Method intersect

fn intersect(b: & BigBitv, nbits: uint) -> bool

Method become

fn become(b: & BigBitv, nbits: uint) -> bool

Method difference

fn difference(b: & BigBitv, nbits: uint) -> bool

Method get

fn get(i: uint) -> bool

Method set

fn set(i: uint, x: bool)

Method equals

fn equals(b: & BigBitv, nbits: uint) -> bool

Implementation for Bitv

Method die

fn die() -> !

Method do_op

fn do_op(op: Op, other: & Bitv) -> bool

Implementation for Bitv

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

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

Method 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

Method clone

fn clone() -> ~Bitv

Makes a copy of a bitvector

Method get

fn get(i: uint) -> bool

Retrieve the value at index i

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

Method equal

fn equal(v1: & Bitv) -> bool

Compares two bitvectors

Both bitvectors must be the same length. Returns true if both bitvectors contain identical elements.

Method clear

fn clear()

Set all bits to 0

Method set_all

fn set_all()

Set all bits to 1

Method invert

fn invert()

Invert all bits

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

Method is_true

fn is_true() -> bool

Returns true if all bits are 1

Method each

fn each(f: fn&(bool) -> bool)

Method is_false

fn is_false() -> bool

Returns true if all bits are 0

Method init_to_vec

fn init_to_vec(i: uint) -> uint

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

Method 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

Method to_bools

fn to_bools() -> ~[bool]

Transform self into a [bool] by turning each bit into a bool

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

Method 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

Method ones

fn ones(f: fn&(uint) -> bool)

Implementation of ops::Index<uint, bool> for Bitv

Method index

fn index(i: uint) -> bool

Function BigBitv

fn BigBitv(storage: ~[mut uint]) -> BigBitv

Function Bitv

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

Function SmallBitv

fn SmallBitv(bits: u32) -> SmallBitv

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

Function from_bools

fn from_bools(bools: & [bool]) -> Bitv

Transform a [bool] into a bitv by converting each bool into a bit.

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

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

Function land

fn land(w0: uint, w1: uint) -> uint

Function lor

fn lor(w0: uint, w1: uint) -> uint

Function right

fn right(_w0: uint, w1: uint) -> uint

Function 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