You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
102 lines
2.2 KiB
102 lines
2.2 KiB
5 years ago
|
(*
|
||
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
||
|
*
|
||
|
* This source code is licensed under the MIT license found in the
|
||
|
* LICENSE file in the root directory of this source tree.
|
||
|
*)
|
||
|
|
||
4 years ago
|
open! NS0
|
||
5 years ago
|
|
||
|
module type S = sig
|
||
|
type elt
|
||
4 years ago
|
type t [@@deriving compare, equal, sexp_of]
|
||
5 years ago
|
|
||
4 years ago
|
module Provide_hash (_ : sig
|
||
|
type t = elt [@@deriving hash]
|
||
|
end) : sig
|
||
|
type t [@@deriving hash]
|
||
|
end
|
||
|
with type t := t
|
||
|
|
||
4 years ago
|
module Provide_of_sexp (_ : sig
|
||
|
type t = elt [@@deriving of_sexp]
|
||
|
end) : sig
|
||
4 years ago
|
type t [@@deriving of_sexp]
|
||
5 years ago
|
end
|
||
4 years ago
|
with type t := t
|
||
5 years ago
|
|
||
4 years ago
|
(** {1 Pretty-print} *)
|
||
|
|
||
|
val pp_full :
|
||
|
?pre:(unit, unit) fmt
|
||
|
-> ?suf:(unit, unit) fmt
|
||
|
-> ?sep:(unit, unit) fmt
|
||
|
-> elt pp
|
||
|
-> t pp
|
||
|
|
||
|
module Provide_pp (_ : sig
|
||
|
type t = elt
|
||
|
|
||
|
val pp : t pp
|
||
|
end) : sig
|
||
|
type t
|
||
|
|
||
|
val pp : t pp
|
||
|
val pp_diff : (t * t) pp
|
||
|
end
|
||
|
with type t := t
|
||
|
|
||
4 years ago
|
(** {1 Construct} *)
|
||
5 years ago
|
|
||
4 years ago
|
val empty : t
|
||
5 years ago
|
val of_ : elt -> t
|
||
|
val of_option : elt option -> t
|
||
4 years ago
|
val of_list : elt list -> t
|
||
4 years ago
|
val add : elt -> t -> t
|
||
5 years ago
|
val add_option : elt option -> t -> t
|
||
|
val add_list : elt list -> t -> t
|
||
4 years ago
|
val remove : elt -> t -> t
|
||
4 years ago
|
val diff : t -> t -> t
|
||
|
val inter : t -> t -> t
|
||
|
val union : t -> t -> t
|
||
5 years ago
|
val diff_inter : t -> t -> t * t
|
||
4 years ago
|
val diff_inter_diff : t -> t -> t * t * t
|
||
4 years ago
|
val union_list : t list -> t
|
||
|
|
||
|
(** {1 Query} *)
|
||
|
|
||
|
val is_empty : t -> bool
|
||
4 years ago
|
val cardinal : t -> int
|
||
4 years ago
|
val mem : elt -> t -> bool
|
||
4 years ago
|
val subset : t -> of_:t -> bool
|
||
5 years ago
|
val disjoint : t -> t -> bool
|
||
4 years ago
|
val max_elt : t -> elt option
|
||
4 years ago
|
val only_elt : t -> elt option
|
||
4 years ago
|
val classify : t -> [`Zero | `One of elt | `Many]
|
||
5 years ago
|
|
||
4 years ago
|
val pop : t -> (elt * t) option
|
||
|
(** Find and remove an unspecified element. [O(1)]. *)
|
||
|
|
||
5 years ago
|
val pop_exn : t -> elt * t
|
||
|
(** Find and remove an unspecified element. [O(1)]. *)
|
||
|
|
||
4 years ago
|
(** {1 Transform} *)
|
||
|
|
||
|
val map : t -> f:(elt -> elt) -> t
|
||
|
val filter : t -> f:(elt -> bool) -> t
|
||
4 years ago
|
val partition : t -> f:(elt -> bool) -> t * t
|
||
4 years ago
|
|
||
|
(** {1 Traverse} *)
|
||
|
|
||
|
val iter : t -> f:(elt -> unit) -> unit
|
||
|
val exists : t -> f:(elt -> bool) -> bool
|
||
|
val for_all : t -> f:(elt -> bool) -> bool
|
||
4 years ago
|
val fold : t -> 's -> f:(elt -> 's -> 's) -> 's
|
||
4 years ago
|
val reduce : t -> f:(elt -> elt -> elt) -> elt option
|
||
4 years ago
|
|
||
|
(** {1 Convert} *)
|
||
|
|
||
|
val to_iter : t -> elt iter
|
||
4 years ago
|
val of_iter : elt iter -> t
|
||
5 years ago
|
end
|