module CCBV:sig
..end
BREAKING CHANGES since 1.2: size is now stored along with the bitvector. Some functions have a new signature.
The size of the bitvector used to be rounded up to the multiple of 30 or 62.
In other words some functions such as CCBV.iter
would iterate on more
bits than what was originally asked for. This is not the case anymore.
type
t
val empty : unit -> t
val create : size:int -> bool -> t
val copy : t -> t
val cardinal : t -> int
val length : t -> int
val capacity : t -> int
val resize : t -> int -> unit
Invalid_arg
on negative sizes.val is_empty : t -> bool
val set : t -> int -> unit
val get : t -> int -> bool
val reset : t -> int -> unit
val flip : t -> int -> unit
val clear : t -> unit
val iter : t -> (int -> bool -> unit) -> unit
val iter_true : t -> (int -> unit) -> unit
val to_list : t -> int list
val to_sorted_list : t -> int list
CCBV.to_list
, but also guarantees the list is sorted in
increasing orderval of_list : int list -> t
The bits are interpreted as indices into the returned bitvector, so the final
bitvector will have length t
equal to 1 more than max of list indices.
val first : t -> int option
val first_exn : t -> int
Not_found
if all bits are 0val filter : t -> (int -> bool) -> unit
filter bv p
only keeps the true bits of bv
whose index
satisfies p index
val negate_self : t -> unit
negate_self t
flips all of the bits in t
.val negate : t -> t
negate t
returns a copy of t
with all of the bits flipped.val union_into : into:t -> t -> unit
union ~into bv
sets into
to the union of itself and bv
.
Also updates the length of into
to be at least length bv
.
val inter_into : into:t -> t -> unit
inter ~into bv
sets into
to the intersection of itself and bv
Also updates the length of into
to be at most length bv
.
val union : t -> t -> t
union bv1 bv2
returns the union of the two setsval inter : t -> t -> t
inter bv1 bv2
returns the intersection of the two setsval diff_into : into:t -> t -> unit
diff ~into t
Modify into
with only the bits set but not in t
.val diff : t -> t -> t
diff t1 t2
Return those bits found t1
but not in t2
.val select : t -> 'a array -> 'a list
select arr bv
selects the elements of arr
whose index
corresponds to a true bit in bv
. If bv
is too short, elements of arr
with too high an index cannot be selected and are therefore not
selected.val selecti : t -> 'a array -> ('a * int) list
CCBV.select
, but selected elements are paired with their indextype'a
sequence =('a -> unit) -> unit
val to_seq : t -> int sequence
val of_seq : int sequence -> t
val print : Format.formatter -> t -> unit