Up

Module type Creators_and_accessors_generic

Signature

include Accessors_generic
include Container.Generic_phantom
type ('a, 'phantom) t
type 'a elt
val mem : ?equal:('a elt -> 'a elt -> bool) -> ('a, _) t -> 'a elt -> bool
val length : (_, _) t -> int
val is_empty : (_, _) t -> bool
val iter : ('a, _) t -> f:('a elt -> unit) -> unit
val fold : ('a, _) t -> init:'accum -> f:('accum -> 'a elt -> 'accum) -> 'accum
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 Commutative_group.S 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 -> cmp:('a elt -> 'a elt -> int) -> 'a elt option
val max_elt : ('a, _) t -> cmp:('a elt -> 'a elt -> int) -> 'a elt option
type ('a, 'cmp) tree
type ('a, 'cmp, 'z) options

The options type is used to make Accessors_generic flexible as to whether a comparator is required to be passed to certain functions.

type 'cmp cmp
val invariants : ('a, 'cmp, ('a, 'cmp) t -> bool) options
val mem : ('a, 'cmp, ('a, 'cmp) t -> 'a elt -> bool) options

override Container's mem

val add : ('a, 'cmp, ('a, 'cmp) t -> 'a elt -> ('a, 'cmp) t) options
val remove : ('a, 'cmp, ('a, 'cmp) t -> 'a elt -> ('a, 'cmp) t) options
val union : ('a, 'cmp, ('a, 'cmp) t -> ('a, 'cmp) t -> ('a, 'cmp) t) options
val inter : ('a, 'cmp, ('a, 'cmp) t -> ('a, 'cmp) t -> ('a, 'cmp) t) options
val diff : ('a, 'cmp, ('a, 'cmp) t -> ('a, 'cmp) t -> ('a, 'cmp) t) options
val symmetric_diff : ('a, 'cmp, ('a, 'cmp) t -> ('a, 'cmp) t -> ('a elt, 'a elt) Either.t Sequence.t) options
val compare_direct : ('a, 'cmp, ('a, 'cmp) t -> ('a, 'cmp) t -> int) options
val equal : ('a, 'cmp, ('a, 'cmp) t -> ('a, 'cmp) t -> bool) options
val subset : ('a, 'cmp, ('a, 'cmp) t -> ('a, 'cmp) t -> bool) options
val fold_until : ('a, _) t -> init:'b -> f:('b -> 'a elt -> [
| `Continue of 'b
| `Stop of 'b
]) -> 'b
val fold_right : ('a, _) t -> init:'b -> f:('a elt -> 'b -> 'b) -> 'b
val iter2 : ('a, 'cmp, ('a, 'cmp) t -> ('a, 'cmp) t -> f:([
| `Left of 'a elt
| `Right of 'a elt
| `Both of 'a elt * 'a elt
] -> unit) -> unit) options
val filter : ('a, 'cmp, ('a, 'cmp) t -> f:('a elt -> bool) -> ('a, 'cmp) t) options
val partition_tf : ('a, 'cmp, ('a, 'cmp) t -> f:('a elt -> bool) -> ('a, 'cmp) t * ('a, 'cmp) t) options
val elements : ('a, _) t -> 'a elt list
val min_elt : ('a, _) t -> 'a elt option
val min_elt_exn : ('a, _) t -> 'a elt
val max_elt : ('a, _) t -> 'a elt option
val max_elt_exn : ('a, _) t -> 'a elt
val choose : ('a, _) t -> 'a elt option
val choose_exn : ('a, _) t -> 'a elt
val split : ('a, 'cmp, ('a, 'cmp) t -> 'a elt -> ('a, 'cmp) t * 'a elt option * ('a, 'cmp) t) options
val group_by : ('a, 'cmp, ('a, 'cmp) t -> equiv:('a elt -> 'a elt -> bool) -> ('a, 'cmp) t list) options
val find_exn : ('a, _) t -> f:('a elt -> bool) -> 'a elt
val find_index : ('a, _) t -> int -> 'a elt option
val remove_index : ('a, 'cmp, ('a, 'cmp) t -> int -> ('a, 'cmp) t) options
val to_tree : ('a, 'cmp) t -> ('a elt, 'cmp) tree
val to_sequence : ('a, 'cmp, ?order:[
| `Increasing
| `Decreasing
] -> ?greater_or_equal_to:'a elt -> ?less_or_equal_to:'a elt -> ('a, 'cmp) t -> 'a elt Sequence.t) options
val merge_to_sequence : ('a, 'cmp, ?order:[
| `Increasing
| `Decreasing
] -> ?greater_or_equal_to:'a elt -> ?less_or_equal_to:'a elt -> ('a, 'cmp) t -> ('a, 'cmp) t -> 'a elt Merge_to_sequence_element.t Sequence.t) options
val to_map : ('a, 'cmp, ('a, 'cmp) t -> f:('a elt -> 'b) -> ('a elt, 'b, 'cmp cmp) Map.t) options
val obs : 'a elt Quickcheck.obs -> ('a, 'cmp) t Quickcheck.obs
val shrinker : ('a, 'cmp, 'a elt Quickcheck.shr -> ('a, 'cmp) t Quickcheck.shr) options
include Creators_generic with type ('a, 'b, 'c) options := ('a, 'b, 'c) options with type ('a, 'b) t := ('a, 'b) t with type ('a, 'b) tree := ('a, 'b) tree with type 'a elt := 'a elt with type 'cmp cmp := 'cmp cmp
type ('a, 'cmp) t
type ('a, 'cmp) set
type ('a, 'cmp) tree
type 'a elt
type ('a, 'cmp, 'z) options
type 'cmp cmp
val empty : ('a, 'cmp, ('a, 'cmp) t) options
val singleton : ('a, 'cmp, 'a elt -> ('a, 'cmp) t) options
val union_list : ('a, 'cmp, ('a, 'cmp) t list -> ('a, 'cmp) t) options
val of_list : ('a, 'cmp, 'a elt list -> ('a, 'cmp) t) options
val of_array : ('a, 'cmp, 'a elt array -> ('a, 'cmp) t) options
val of_sorted_array : ('a, 'cmp, 'a elt array -> ('a, 'cmp) t Or_error.t) options
val of_sorted_array_unchecked : ('a, 'cmp, 'a elt array -> ('a, 'cmp) t) options
val stable_dedup_list : ('a, _, 'a elt list -> 'a elt list) options
val map : ('b, 'cmp, ('a, _) set -> f:('a -> 'b elt) -> ('b, 'cmp) t) options

The types of map and filter_map are subtle. The input set, ('a, _) set, reflects the fact that these functions take a set of *any* type, with any comparator, while the output set, ('b, 'cmp) t, reflects that the output set has the particular 'cmp of the creation function. The comparator can come in one of three ways, depending on which set module is used

  • Set.map -- comparator comes as an argument
  • Set.Poly.map -- comparator is polymorphic comparison
  • Foo.Set.map -- comparator is Foo.comparator
val filter_map : ('b, 'cmp, ('a, _) set -> f:('a -> 'b elt option) -> ('b, 'cmp) t) options
val of_tree : ('a, 'cmp, ('a elt, 'cmp) tree -> ('a, 'cmp) t) options
val of_map_keys : ('a elt, _, 'cmp cmp) Map.t -> ('a, 'cmp) t

never requires a comparator because it can get one from the input Map.t

val gen : ('a, 'cmp, 'a elt Quickcheck.Generator.t -> ('a, 'cmp) t Quickcheck.Generator.t) options