package core_extended

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

This module implements efficient and compact arrays of boolean values. It stores its values in the bits of an integer, using multiple integers to allow for arrays larger than the machine word size. All operations are on immediates (no caml_modify), and are quite simple. Hence this data structure should be more efficient than an array of bools.

type t
include Core.Sexpable with type t := t
val t_of_sexp : Sexplib0__.Sexp.t -> t
val sexp_of_t : t -> Sexplib0__.Sexp.t
val create : int -> t

create size size must be less than ((word size - 2) * max array length)

val get : t -> int -> bool

get t pos get the value in position pos, raises Invalid_argument if the position is out of bounds.

val set : t -> int -> bool -> unit

set t pos set the value in position pos, raises Invalid_argument if the position is out of bounds.

val clear : t -> unit

clear t set the contents of every element to false O(n / (word_size - 2))

val fold : t -> init:'a -> f:('a -> bool -> 'a) -> 'a

fold t ~init ~f Fold over the array as in Array.fold

val iter : t -> f:(bool -> unit) -> unit

iter t ~f Iterate over the array as in Array.iter

val length : t -> int

length t returns the length of t, i.e., the number of bits it contains

val count : ?len:int -> t -> int

count t returns the number of bits set to true in t.

When len is provided, only count the first len bits.

OCaml

Innovation. Community. Security.