Next: , Previous: , Up: bitvectors   [Index]


43.3 Bitwise operations on bitvectors

The following bindings are exported by the library (vicare containers bitvectors).

Method on <bitvector>: () bit-set! {bit-index <non-negative-exact-integer>} bool

Set the bit at bit-index in the <bitvector> to one if bool is non–false, or to zero if bool is #f.

Method on <bitvector>: <boolean> bit-ref {bit-index <non-negative-exact-integer>}

Return a boolean representing the bit at bit-index in the <bitvector>.

Method on <bitvector>: () set-all!
Method on <bitvector>: () clear-all!

Set all the bits to true or to false.

Method on <bitvector>: () toggle! bit-index

Invert the bit at bit-index.

Method on <bitvector>: <bitvector> not

Apply the bitwise NOT to the instance and return a new <bitvector> object holding the result.

Method on <bitvector>: <bitvector> not!

Mutate this instance by applying the bitwise NOT operation and storing the result in the instance itself. The return value is the instance object itself.

Method on <bitvector>: <bitvector> and {B <bitvector>}
Method on <bitvector>: <bitvector> ior {B <bitvector>}
Method on <bitvector>: <bitvector> xor {B <bitvector>}

Apply the bitwise AND, inclusive OR or exclusive OR to the instance and B, then return a new <bitvector> object representing the result. B must have the same length of the instance.

Method on <bitvector>: <bitvector> and! {B <bitvector>}
Method on <bitvector>: <bitvector> ior! {B <bitvector>}
Method on <bitvector>: <bitvector> xor! {B <bitvector>}

Mutate this instance by applying the bitwise AND, inclusive OR or exclusive OR to the instance and B and storing the result in the instance itself. B must have the same length of the instance.

Method on <bitvector>: <non-negative-exact-integer> bit-count

Return an exact integer being the number of bits set to true.

Method on <bitvector>: <exact-integer> first-bit-set

Return an exact integer being the offset of the first bit set to true; if all the bits are set to false: return -1.


Next: , Previous: , Up: bitvectors   [Index]