Module Base.Hash_set

type !'a t
val sexp_of_t : ('a -> Sexplib0.Sexp.t) -> 'a t -> Sexplib0.Sexp.t

We use [@@deriving sexp_of] but not [@@deriving sexp] because we want people to be explicit about the hash and comparison functions used when creating hashtables. One can use Hash_set.Poly.t, which does have [@@deriving sexp], to use polymorphic comparison and hashing.

module Key = Hashtbl.Key
module type Creators = sig ... end
module type Creators_generic = sig ... end
module type For_deriving = sig ... end
type nonrec ('key, 'z) create_options = ?growth_allowed:bool -> ?size:int -> 'key Hashtbl.Key.t -> 'z
include Creators with type 'a t := 'a t
val create : ?growth_allowed:bool -> ?size:int -> 'a Hashtbl.Key.t -> 'a t
val of_list : ?growth_allowed:bool -> ?size:int -> 'a Hashtbl.Key.t -> 'a list -> 'a t
module type Accessors = sig ... end
include Accessors with type 'a t := 'a t with type 'a elt = 'a
include Container.Generic with type ('a, _) t := 'a t with type 'a elt = 'a
type 'a elt = 'a
val length : _ t -> int
val is_empty : _ t -> bool
val iter : 'a t -> f:('a elt -> unit) -> unit
val fold : 'a t -> init:'acc -> f:('acc -> 'a elt -> 'acc) -> 'acc
val fold_result : 'a t -> init:'acc -> f:('acc -> 'a elt -> ('acc, 'e) Result.t) -> ('acc, 'e) Result.t
val fold_until : 'a t -> init:'acc -> f:('acc -> 'a elt -> ('acc, 'final) Container.Continue_or_stop.t) -> finish:('acc -> 'final) -> 'final
val exists : 'a t -> f:('a elt -> bool) -> bool
val for_all : 'a t -> f:('a elt -> bool) -> bool
val count : 'a t -> f:('a elt -> bool) -> int
val sum : (module Container.Summable with type t = 'sum) -> 'a t -> f:('a elt -> 'sum) -> 'sum
val find : 'a t -> f:('a elt -> bool) -> 'a elt option
val find_map : 'a t -> f:('a elt -> 'b option) -> 'b option
val to_list : 'a t -> 'a elt list
val to_array : 'a t -> 'a elt array
val min_elt : 'a t -> compare:('a elt -> 'a elt -> int) -> 'a elt option
val max_elt : 'a t -> compare:('a elt -> 'a elt -> int) -> 'a elt option
val mem : 'a t -> 'a -> bool

override Container.Generic.mem

val copy : 'a t -> 'a t

preserves the equality function

val add : 'a t -> 'a -> unit
val strict_add : 'a t -> 'a -> unit Or_error.t

strict_add t x returns Ok () if the x was not in t, or an Error if it was.

val strict_add_exn : 'a t -> 'a -> unit
val remove : 'a t -> 'a -> unit
val strict_remove : 'a t -> 'a -> unit Or_error.t

strict_remove t x returns Ok () if the x was in t, or an Error if it was not.

val strict_remove_exn : 'a t -> 'a -> unit
val clear : 'a t -> unit
val equal : 'a t -> 'a t -> bool
val filter : 'a t -> f:('a -> bool) -> 'a t
val filter_inplace : 'a t -> f:('a -> bool) -> unit
val inter : 'key t -> 'key t -> 'key t

inter t1 t2 computes the set intersection of t1 and t2. Runs in O(min(length t1, length t2)). Behavior is undefined if t1 and t2 don't have the same equality function.

val union : 'a t -> 'a t -> 'a t
val diff : 'a t -> 'a t -> 'a t
val of_hashtbl_keys : ('a, _) Hashtbl.t -> 'a t
val to_hashtbl : 'key t -> f:('key -> 'data) -> ('key, 'data) Hashtbl.t
val hashable_s : 'key t -> 'key Key.t
type nonrec ('key, 'z) create_options_without_first_class_module = ?growth_allowed:bool -> ?size:int -> 'z
module Poly : sig ... end

A hash set that uses polymorphic comparison

module Creators (Elt : sig ... end) : sig ... end
include For_deriving with type 'a t := 'a t
module type M_of_sexp = sig ... end
module type Sexp_of_m = sig ... end
module type Equal_m = sig ... end
module M (Elt : T.T) : sig ... end

M is meant to be used in combination with OCaml applicative functor types:

val sexp_of_m__t : (module Sexp_of_m with type t = 'elt) -> 'elt t -> Sexp.t
val m__t_of_sexp : (module M_of_sexp with type t = 'elt) -> Sexp.t -> 'elt t
val m__t_sexp_grammar : (module Base__.Hash_set_intf.M_sexp_grammar with type t = 'elt) -> 'elt t Sexplib0.Sexp_grammar.t
val equal_m__t : (module Equal_m) -> 'elt t -> 'elt t -> bool