![]() |
![]() |
![]() |
|
Bitvector is in principle array of bools. However more space-efficient implementation is provided then <bool>Array::t. Additionally standard bit-operations are available. | |
type t; | |
Type of bitvectors. | |
t make(int size, bool ini); | |
Return fresh bitvector, of size elements (bits), will set all of them to ini. | |
t init(int size, *(bool (int)) f); | |
Return fresh bitvector, of size elements (bits). Elements are initialized by calling f(0), f(1), ..., f(size-1) and storing return values. | |
bool get(t b, int i); | |
Return value of element number i of bitvector b. Raise Invalid_argument if i is outside allowed range 0 -- Bitvector::length(b) - 1. | |
void set(t b, int i, bool v); | |
Set element number i of bitvector b to v. Raise Invalid_argument if i is outside allowed range 0 -- Bitvector::length(b) - 1. | |
int length(t b); | |
Return number of elements (bits) in bitvector b. | |
void resize(t b, int new_size, bool ini); | |
Resize b to be new_size bit long. If bitvector grows, new elements are all initialized to ini. | |
t copy(t src); | |
Return fresh bitvector, initialized to contents of bitvector src. | |
void or(t dst, t src); | |
Perform logical OR on bits of dst and src. Result is stored in dst. If dst is smaller then src, it is zero-padded. If src is smaller then dst it is virtually zero-padded (it is not changed, but operation is performed as if it was grown with zeros). | |
void and(t dst, t src); | |
Same as Bitvector::or, but performs logical AND. | |
void xor(t dst, t src); | |
Same as Bitvector::or, but performs logical XOR. |