package fast_bitvector

  1. Overview
  2. Docs

Module Fast_bitvectorSource

Sourcetype t
include Sexplib0.Sexpable.S with type t := t
Sourceval t_of_sexp : Sexplib0.Sexp.t -> t
Sourceval sexp_of_t : t -> Sexplib0.Sexp.t
Sourceval max_length : int

Maximum length of any bitvector. Depends on host architecture.

Sourceval create : len:int -> t

Create a bitvector filled with zeroes of length len.

Sourceval create_full : len:int -> t

Create a bitvector filled with ones of size len.

module type Ops := sig ... end
Sourcemodule Unsafe : Ops with type with_result := dst:t -> unit

dst specifies the destination bitvector of the operation, for inplace operations, specify one of the operands as dst `

include Ops with type with_result := dst:t -> unit
Sourceval set : t -> int -> unit
Sourceval clear : t -> int -> unit
Sourceval set_to : t -> int -> bool -> unit
Sourceval get : t -> int -> bool
Sourceval equal : t -> t -> bool

Compare two bitvectors for equality.

Sourceval equal_modulo : modulo:t -> t -> t -> bool

Test whether two bitvectors are equal in the positions set in modulo

Sourceval not : t -> dst:t -> unit
Sourceval and_ : t -> t -> dst:t -> unit
Sourceval nand : t -> t -> dst:t -> unit
Sourceval or_ : t -> t -> dst:t -> unit
Sourceval nor : t -> t -> dst:t -> unit
Sourceval xor : t -> t -> dst:t -> unit
Sourceval xnor : t -> t -> dst:t -> unit
Sourcemodule Set : sig ... end
Sourcemodule Allocate : sig ... end
Sourcemodule Bit_zero_first : sig ... end
Sourcemodule Bit_zero_last : sig ... end
Sourceval length : t -> int

Returns length of the given bitvector.

Sourceval copy : t -> t

Creates a copy of bitvector v.

Sourceval append : t -> t -> t

Creates a fresh bitvector that is the concatenation of v1 and v2.

Sourceval popcount : t -> int

Creates a fresh bitvector that is the concatenation of v1 and v2.

Return the count of bits set to one.

Sourceval set_all : t -> unit

Set all bits to one.

Sourceval clear_all : t -> unit

Set all bits to zero.

Sourceval randomize : t -> unit

Set all bits to random values.

Sourceval is_empty : t -> bool

Return true whenever all bits are zero.

Sourceval is_full : t -> bool

Return true whenever all bits are one.

Iterators

Sourceval fold_left : t -> init:'a -> f:('a -> bool -> 'a) -> 'a

fold ~init ~f b0...bn is f (f (f init b0)...) bn, where b0...bn are individual bits in a bitvector.

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

Alias for fold_left

Sourceval fold_lefti : t -> init:'a -> f:('a -> int -> bool -> 'a) -> 'a

fold_lefti is fold_left with offset provided.

Sourceval fold_left_set : t -> init:'a -> f:('a -> int -> 'a) -> 'a

fold over all offsets of set bits.

Sourceval fold_set : t -> init:'a -> f:('a -> int -> 'a) -> 'a

Alias for fold_left_set

Sourceval foldi : t -> init:'a -> f:('a -> int -> bool -> 'a) -> 'a

Alias for fold_lefti

Sourceval fold_right : t -> init:'a -> f:(bool -> 'a -> 'a) -> 'a

fold ~init ~f b0...bn is f (f (f init b0)...) bn, where b0...bn are individual bits in a bitvector.

Sourceval fold_righti : t -> init:'a -> f:(int -> bool -> 'a -> 'a) -> 'a

foldi is fold with offset provided.

Sourceval fold_right_set : t -> init:'a -> f:(int -> 'a -> 'a) -> 'a

fold over all offsets of set bits.

Sourceval map : t -> f:(bool -> bool) -> t

Map every bit in the vector with function f.

Sourceval mapi : t -> f:(int -> bool -> bool) -> t

mapi ~f b0...bn is f 0 b0 ... f n bn, where bi is i-th bit in a bitvector.

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

Iterate over all bits.

Sourceval iteri : t -> f:(int -> bool -> unit) -> unit

Iterate over all bits and their offsets.

Sourceval iter_set : t -> f:(int -> unit) -> unit

Iterate over all offsets of set bits.

Sourceval rev_iteri : t -> f:(int -> bool -> unit) -> unit

Iterate over all bits and their offsets in reverse order.

Sourceval rev_iter : t -> f:(bool -> unit) -> unit

Iterate over all bits in reverse order.

Sourceval rev_iter_set : t -> f:(int -> unit) -> unit

Iterate over all offsets of set bits in reverse order.

Sourcemodule Builder : sig ... end
Sourcemodule Private : sig ... end
OCaml

Innovation. Community. Security.