[src]

Struct collections::bitv::Bitv

pub struct Bitv {
    // some fields omitted
}

The bitvector type

Methods

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)

Flip 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) -> Bits<'a>

fn rev_iter<'a>(&'a self) -> Rev<Bits<'a>>

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: |uint| -> bool) -> bool

Trait Implementations

impl Index<uint, bool> for Bitv

fn index(&self, i: &uint) -> bool

Derived Implementations

impl Clone for Bitv

fn clone(&self) -> Bitv