1 type t = { length : int;
4 let create ?(init=false) size =
5 let i = if init then '\xff' else '\x00' in
7 bits = String.make (1 + size / 8) i
10 let length v = v.length
15 (((Char.code (String.unsafe_get v.bits i)) lsr j) land 1) == 1
18 let unsafe_set v n (b:bool) =
19 let x : int = Obj.magic b in
23 let w = Char.code (String.unsafe_get v.bits i) in
24 let w = (w land lnot m) lor (~-x land m) in
25 String.unsafe_set v.bits i (Char.unsafe_chr (w land 0xff))
29 if n < 0 || n >= v.length then failwith "Bitvector.get"
34 if n < 0 || n >= v.length then failwith "Bitvector.set"