Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion jscomp/others/belt_HashSet.ml
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ let has h key =



let make (type elt) (type identity) ~hintSize ~(id: (elt, identity) id)=
let make (type value) (type identity) ~hintSize ~(id: (value, identity) id)=
let module M = (val id) in
C.make ~hintSize ~hash:M.hash ~eq:M.eq

Expand Down
12 changes: 6 additions & 6 deletions jscomp/others/belt_MutableSet.ml
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ type ('k, 'id) id = ('k, 'id) Belt_Id.comparable
type ('key, 'id ) cmp = ('key, 'id) Belt_Id.cmp

module S = struct
type ('elt,'id) t =
type ('value,'id) t =
{
cmp: ('elt, 'id) cmp;
mutable data: 'elt N.t
cmp: ('value, 'id) cmp;
mutable data: 'value N.t
} [@@bs.deriving abstract]
end

Expand Down Expand Up @@ -189,7 +189,7 @@ let mergeMany d xs =
S.dataSet d (addArrayMutate (S.data d) xs ~cmp:(S.cmp d))


let make (type elt) (type identity) ~(id : (elt, identity) id) =
let make (type value) (type identity) ~(id : (value, identity) id) =
let module M = (val id) in
S.t ~cmp:M.cmp ~data:N.empty

Expand Down Expand Up @@ -220,15 +220,15 @@ let toList d =
let toArray d =
N.toArray (S.data d)

let ofSortedArrayUnsafe (type elt) (type identity) xs ~(id : (elt,identity) id) : _ t =
let ofSortedArrayUnsafe (type value) (type identity) xs ~(id : (value,identity) id) : _ t =
let module M = (val id) in
S.t ~data:(N.ofSortedArrayUnsafe xs) ~cmp:M.cmp

let checkInvariantInternal d =
N.checkInvariantInternal (S.data d)


let ofArray (type elt) (type identity) data ~(id : (elt,identity) id) =
let ofArray (type value) (type identity) data ~(id : (value,identity) id) =
let module M = (val id) in
let cmp = M.cmp in
S.t ~cmp ~data:(N.ofArray ~cmp data)
Expand Down
82 changes: 41 additions & 41 deletions jscomp/others/belt_MutableSet.mli
Original file line number Diff line number Diff line change
Expand Up @@ -87,88 +87,88 @@ type ('k,'id) t

type ('k, 'id) id = ('k, 'id) Belt_Id.comparable

val make: id:('elt, 'id) id -> ('elt, 'id) t
val make: id:('value, 'id) id -> ('value, 'id) t

val ofArray: 'k array -> id:('k, 'id) id -> ('k, 'id) t
val ofSortedArrayUnsafe: 'elt array -> id:('elt, 'id) id -> ('elt,'id) t
val ofSortedArrayUnsafe: 'value array -> id:('value, 'id) id -> ('value,'id) t
val copy: ('k, 'id) t -> ('k, 'id) t
val isEmpty: _ t -> bool
val has: ('elt, _) t -> 'elt -> bool
val has: ('value, _) t -> 'value -> bool

val add: ('elt, 'id) t -> 'elt -> unit
val add: ('value, 'id) t -> 'value -> unit

val addCheck:
('elt, 'id) t -> 'elt -> bool
('value, 'id) t -> 'value -> bool

val mergeMany:
('elt, 'id) t -> 'elt array -> unit
('value, 'id) t -> 'value array -> unit

val remove: ('elt, 'id) t -> 'elt -> unit
val remove: ('value, 'id) t -> 'value -> unit

val removeCheck: ('elt, 'id) t -> 'elt -> bool
val removeCheck: ('value, 'id) t -> 'value -> bool
(* [b = removeCheck s e] [b] is true means one element removed *)

val removeMany:
('elt, 'id) t -> 'elt array -> unit
('value, 'id) t -> 'value array -> unit

val union: ('elt, 'id) t -> ('elt, 'id) t -> ('elt, 'id) t
val intersect: ('elt, 'id) t -> ('elt, 'id) t -> ('elt, 'id) t
val diff: ('elt, 'id) t -> ('elt, 'id) t -> ('elt, 'id) t
val subset: ('elt, 'id) t -> ('elt, 'id) t -> bool
val union: ('value, 'id) t -> ('value, 'id) t -> ('value, 'id) t
val intersect: ('value, 'id) t -> ('value, 'id) t -> ('value, 'id) t
val diff: ('value, 'id) t -> ('value, 'id) t -> ('value, 'id) t
val subset: ('value, 'id) t -> ('value, 'id) t -> bool

val cmp:
('elt, 'id) t -> ('elt, 'id) t -> int
('value, 'id) t -> ('value, 'id) t -> int
val eq:
('elt, 'id) t -> ('elt, 'id) t -> bool
('value, 'id) t -> ('value, 'id) t -> bool

val forEachU: ('elt, 'id) t -> ('elt -> unit [@bs]) -> unit
val forEach: ('elt, 'id) t -> ('elt -> unit) -> unit
val forEachU: ('value, 'id) t -> ('value -> unit [@bs]) -> unit
val forEach: ('value, 'id) t -> ('value -> unit) -> unit
(** [forEach m f] applies [f] in turn to all elements of [m].
In increasing order *)

val reduceU: ('elt, 'id) t -> 'a -> ('a -> 'elt -> 'a [@bs]) -> 'a
val reduce: ('elt, 'id) t -> 'a -> ('a -> 'elt -> 'a) -> 'a
val reduceU: ('value, 'id) t -> 'a -> ('a -> 'value -> 'a [@bs]) -> 'a
val reduce: ('value, 'id) t -> 'a -> ('a -> 'value -> 'a) -> 'a
(** In increasing order. *)

val everyU: ('elt, 'id) t -> ('elt -> bool [@bs]) -> bool
val every: ('elt, 'id) t -> ('elt -> bool) -> bool
val everyU: ('value, 'id) t -> ('value -> bool [@bs]) -> bool
val every: ('value, 'id) t -> ('value -> bool) -> bool
(** [every s p] checks if all elements of the set
satisfy the predicate [p]. Order unspecified *)

val someU: ('elt, 'id) t -> ('elt -> bool [@bs]) -> bool
val some: ('elt, 'id) t -> ('elt -> bool) -> bool
val someU: ('value, 'id) t -> ('value -> bool [@bs]) -> bool
val some: ('value, 'id) t -> ('value -> bool) -> bool
(** [some p s] checks if at least one element of
the set satisfies the predicate [p]. *)

val keepU: ('elt, 'id) t -> ('elt -> bool [@bs]) -> ('elt, 'id) t
val keep: ('elt, 'id) t -> ('elt -> bool) -> ('elt, 'id) t
val keepU: ('value, 'id) t -> ('value -> bool [@bs]) -> ('value, 'id) t
val keep: ('value, 'id) t -> ('value -> bool) -> ('value, 'id) t
(** [keep s p] returns the set of all elements in [s]
that satisfy predicate [p]. *)

val partitionU: ('elt, 'id) t -> ('elt -> bool [@bs]) -> ('elt, 'id) t * ('elt, 'id) t
val partition: ('elt, 'id) t -> ('elt -> bool) -> ('elt, 'id) t * ('elt, 'id) t
val partitionU: ('value, 'id) t -> ('value -> bool [@bs]) -> ('value, 'id) t * ('value, 'id) t
val partition: ('value, 'id) t -> ('value -> bool) -> ('value, 'id) t * ('value, 'id) t
(** [partition p s] returns a pair of sets [(s1, s2)], where
[s1] is the set of all the elements of [s] that satisfy the
predicate [p], and [s2] is the set of all the elements of
[s] that do not satisfy [p]. *)


val size: ('elt, 'id) t -> int
val toList: ('elt, 'id) t -> 'elt list
val size: ('value, 'id) t -> int
val toList: ('value, 'id) t -> 'value list
(** In increasing order*)
val toArray: ('elt, 'id) t -> 'elt array
val toArray: ('value, 'id) t -> 'value array

val minimum: ('elt, 'id) t -> 'elt option
val minUndefined: ('elt, 'id) t -> 'elt Js.undefined
val maximum: ('elt, 'id) t -> 'elt option
val maxUndefined: ('elt, 'id) t -> 'elt Js.undefined
val minimum: ('value, 'id) t -> 'value option
val minUndefined: ('value, 'id) t -> 'value Js.undefined
val maximum: ('value, 'id) t -> 'value option
val maxUndefined: ('value, 'id) t -> 'value Js.undefined

val get: ('elt, 'id) t -> 'elt -> 'elt option
val getUndefined: ('elt, 'id) t -> 'elt -> 'elt Js.undefined
val getExn: ('elt, 'id) t -> 'elt -> 'elt
val get: ('value, 'id) t -> 'value -> 'value option
val getUndefined: ('value, 'id) t -> 'value -> 'value Js.undefined
val getExn: ('value, 'id) t -> 'value -> 'value


val split: ('elt, 'id) t -> 'elt -> (('elt, 'id) t * ('elt, 'id) t) * bool
val split: ('value, 'id) t -> 'value -> (('value, 'id) t * ('value, 'id) t) * bool
(** [split s x] returns a triple [((l, r), present)], where
[l] is the set of elements of [s] that are
strictly less than [x];
Expand All @@ -187,8 +187,8 @@ val checkInvariantInternal: _ t -> unit
(*
[add0] was not exposed for various reasons:
1. such api is dangerious
[ cmp: ('elt,'id) Belt_Cmp.cmp ->
('elt, 'id) t0 -> 'elt ->
('elt, 'id) t0]
[ cmp: ('value,'id) Belt_Cmp.cmp ->
('value, 'id) t0 -> 'value ->
('value, 'id) t0]
2. It is not really significantly more *)

8 changes: 4 additions & 4 deletions jscomp/others/belt_MutableSetInt.ml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ module S = Belt_SortArrayInt
module N = Belt_internalAVLset
module A = Belt_Array

type elt = I.elt
type value = I.value
(** The type of the set elements. *)


Expand All @@ -45,7 +45,7 @@ type t = {
(** The type of sets. *)


let rec remove0 nt (x : elt)=
let rec remove0 nt (x : value)=
let k = N.key nt in
if x = k then
let l,r = N.(left nt, right nt) in
Expand Down Expand Up @@ -98,7 +98,7 @@ let removeMany (d : t) xs =
let len = A.length xs in
dataSet d (removeMany0 nt xs 0 len)

let rec removeCheck0 nt (x : elt) removed =
let rec removeCheck0 nt (x : value) removed =
let k = N.key nt in
if x = k then
let () = removed := true in
Expand Down Expand Up @@ -139,7 +139,7 @@ let removeCheck (d : t) v =
!removed


let rec addCheck0 t (x : elt) added =
let rec addCheck0 t (x : value) added =
match N.toOpt t with
| None ->
added := true;
Expand Down
66 changes: 33 additions & 33 deletions jscomp/others/belt_MutableSetInt.mli
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@


# 37
type elt = int
type value = int
# 41
(** The type of the set elements. *)

Expand All @@ -43,18 +43,18 @@ type t

val make: unit -> t

val ofArray: elt array -> t
val ofSortedArrayUnsafe: elt array -> t
val ofArray: value array -> t
val ofSortedArrayUnsafe: value array -> t
val copy: t -> t
val isEmpty: t -> bool
val has: t -> elt -> bool

val add: t -> elt -> unit
val addCheck: t -> elt -> bool
val mergeMany: t -> elt array -> unit
val remove: t -> elt -> unit
val removeCheck: t -> elt -> bool
val removeMany: t -> elt array -> unit
val has: t -> value -> bool

val add: t -> value -> unit
val addCheck: t -> value -> bool
val mergeMany: t -> value array -> unit
val remove: t -> value -> unit
val removeCheck: t -> value -> bool
val removeMany: t -> value array -> unit

val union: t -> t -> t
val intersect: t -> t -> t
Expand All @@ -65,51 +65,51 @@ val cmp: t -> t -> int
val eq: t -> t -> bool


val forEachU: t -> (elt -> unit [@bs]) -> unit
val forEach: t -> (elt -> unit ) -> unit
val forEachU: t -> (value -> unit [@bs]) -> unit
val forEach: t -> (value -> unit ) -> unit
(** In increasing order*)

val reduceU: t -> 'a -> ('a -> elt -> 'a [@bs]) -> 'a
val reduce: t -> 'a -> ('a -> elt -> 'a ) -> 'a
val reduceU: t -> 'a -> ('a -> value -> 'a [@bs]) -> 'a
val reduce: t -> 'a -> ('a -> value -> 'a ) -> 'a
(** Iterate in increasing order. *)

val everyU: t -> (elt -> bool [@bs]) -> bool
val every: t -> (elt -> bool) -> bool
val everyU: t -> (value -> bool [@bs]) -> bool
val every: t -> (value -> bool) -> bool
(** [every p s] checks if all elements of the set
satisfy the predicate [p]. Order unspecified. *)

val someU: t -> (elt -> bool [@bs]) -> bool
val some: t -> (elt -> bool) -> bool
val someU: t -> (value -> bool [@bs]) -> bool
val some: t -> (value -> bool) -> bool
(** [some p s] checks if at least one element of
the set satisfies the predicate [p]. Oder unspecified. *)

val keepU: t -> (elt -> bool [@bs]) -> t
val keep: t -> (elt -> bool) -> t
val keepU: t -> (value -> bool [@bs]) -> t
val keep: t -> (value -> bool) -> t
(** [keep s p] returns a fresh copy of the set of all elements in [s]
that satisfy predicate [p]. *)

val partitionU: t -> (elt -> bool [@bs]) -> t * t
val partition: t -> (elt -> bool) -> t * t
val partitionU: t -> (value -> bool [@bs]) -> t * t
val partition: t -> (value -> bool) -> t * t
(** [partition s p] returns a fresh copy pair of sets [(s1, s2)], where
[s1] is the set of all the elements of [s] that satisfy the
predicate [p], and [s2] is the set of all the elements of
[s] that do not satisfy [p]. *)

val size: t -> int
val toList: t -> elt list
val toList: t -> value list
(** In increasing order with respect *)
val toArray: t -> elt array
val toArray: t -> value array


val minimum: t -> elt option
val minUndefined: t -> elt Js.undefined
val maximum: t -> elt option
val maxUndefined: t -> elt Js.undefined
val minimum: t -> value option
val minUndefined: t -> value Js.undefined
val maximum: t -> value option
val maxUndefined: t -> value Js.undefined

val get: t -> elt -> elt option
val getUndefined: t -> elt -> elt Js.undefined
val getExn: t -> elt -> elt
val split: t -> elt -> (t * t) * bool
val get: t -> value -> value option
val getUndefined: t -> value -> value Js.undefined
val getExn: t -> value -> value
val split: t -> value -> (t * t) * bool
(**
[split s key] return a fresh copy of each
*)
Expand Down
8 changes: 4 additions & 4 deletions jscomp/others/belt_MutableSetString.ml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ module S = Belt_SortArrayString
module N = Belt_internalAVLset
module A = Belt_Array

type elt = I.elt
type value = I.value
(** The type of the set elements. *)


Expand All @@ -45,7 +45,7 @@ type t = {
(** The type of sets. *)


let rec remove0 nt (x : elt)=
let rec remove0 nt (x : value)=
let k = N.key nt in
if x = k then
let l,r = N.(left nt, right nt) in
Expand Down Expand Up @@ -98,7 +98,7 @@ let removeMany (d : t) xs =
let len = A.length xs in
dataSet d (removeMany0 nt xs 0 len)

let rec removeCheck0 nt (x : elt) removed =
let rec removeCheck0 nt (x : value) removed =
let k = N.key nt in
if x = k then
let () = removed := true in
Expand Down Expand Up @@ -139,7 +139,7 @@ let removeCheck (d : t) v =
!removed


let rec addCheck0 t (x : elt) added =
let rec addCheck0 t (x : value) added =
match N.toOpt t with
| None ->
added := true;
Expand Down
Loading