Skip to content

Commit

Permalink
Merge pull request #9 from bobot/add_copy_function
Browse files Browse the repository at this point in the history
Add a copy function
  • Loading branch information
pascutto committed Nov 28, 2021
2 parents 6ba5f8f + 7228abb commit 084961d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
@@ -1,3 +1,7 @@
# unreleased

- Added `copy`

# v0.2.0 2021-02-10

- Added `to_bytes` and `of_bytes`.
Expand Down
2 changes: 2 additions & 0 deletions src/bloomf.ml
@@ -1,6 +1,7 @@
type priv = { m : int; k : int; p_len : (int * int) list; b : Bitv.t }
type 'a t = priv

let copy t = { m = t.m; k = t.k; p_len = t.p_len; b = Bitv.copy t.b }
let rec gcd a b = if b = 0 then a else gcd b (a mod b)

let partition_lengths m k =
Expand Down Expand Up @@ -142,6 +143,7 @@ module Make (H : Hashable) = struct
type t = priv

let create = create
let copy = copy
let add bf data = add_priv bf (H.hash data)
let mem bf data = mem_priv bf (H.hash data)
let clear = clear
Expand Down
5 changes: 5 additions & 0 deletions src/bloomf.mli
Expand Up @@ -22,6 +22,10 @@ val create : ?error_rate:float -> int -> 'a t
@raise Invalid_argument
if [error_rate] is not in \]0, 1\[, or [size] is negative. *)

val copy : 'a t -> 'a t
(** [copy t] copies the BF. The fresh returned BF is completely separated from
the given one. *)

val add : 'a t -> 'a -> unit
(** [add t e] adds [e] to [t]. *)

Expand Down Expand Up @@ -79,6 +83,7 @@ module Make (H : Hashable) : sig
type t

val create : ?error_rate:float -> int -> t
val copy : t -> t
val add : t -> H.t -> unit
val mem : t -> H.t -> bool
val clear : t -> unit
Expand Down

0 comments on commit 084961d

Please sign in to comment.