Skip to content

Commit

Permalink
Merge 46beefe into 009f726
Browse files Browse the repository at this point in the history
  • Loading branch information
bobzhang committed Dec 30, 2017
2 parents 009f726 + 46beefe commit 5e87199
Show file tree
Hide file tree
Showing 22 changed files with 336 additions and 344 deletions.
2 changes: 1 addition & 1 deletion jscomp/others/bs_Array.ml
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ let foldLeft a x f =
let foldRight a x f =
let r = ref x in
for i = length a - 1 downto 0 do
r := f (unsafe_get a i) !r [@bs]
r := f !r (unsafe_get a i) [@bs]
done;
!r

Expand Down
2 changes: 1 addition & 1 deletion jscomp/others/bs_Array.mli
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ val mapi : 'a array -> (int -> 'a -> 'b [@bs]) -> 'b array

val foldLeft : 'b array -> 'a -> ('a -> 'b -> 'a [@bs]) ->'a

val foldRight : 'b array -> 'a -> ('b -> 'a -> 'a [@bs]) -> 'a
val foldRight : 'b array -> 'a -> ('a -> 'b -> 'a [@bs]) -> 'a

val forAll : 'a array -> ('a -> bool [@bs]) -> bool

Expand Down
29 changes: 14 additions & 15 deletions jscomp/others/bs_Set.ml
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ type ('elt,'id) t = (('elt,'id) Bs_Cmp.t , ('elt,'id) t0) B.bag
let empty0 = N.empty0
let isEmpty0 = N.isEmpty0
let singleton0 = N.singleton0
let min0 = N.min0
let max0 = N.max0
let minOpt0 = N.minOpt0
let maxOpt0 = N.maxOpt0
let iter0 = N.iter0
let fold0 = N.fold0
let forAll0 = N.forAll0
let exists0 = N.exists0
let filter0 = N.filter0
let partition0 = N.partition0
let length0 = N.length0
let elements0 = N.elements0
let toList0 = N.toList0
let toArray0 = N.toArray0
(* Insertion of one element *)

Expand Down Expand Up @@ -268,30 +268,29 @@ let subset (type elt) (type id) (m : (elt,id) t) (n : (elt,id) t) =
let module M = (val dict) in
subset0 ~cmp:M.cmp mdata ndata

let iter f m = iter0 f (B.data m)
let iter m f = iter0 (B.data m) f

let fold f m acc = fold0 f (B.data m) acc
let fold m acc f = fold0 (B.data m) acc f

let forAll f m = forAll0 f (B.data m)
let forAll m f = forAll0 (B.data m) f

let exists f m = exists0 f (B.data m)
let exists m f = exists0 (B.data m) f

let filter f m =
let filter m f =
let data, dict = B.(data m, dict m) in
B.bag ~dict ~data:(filter0 f data)
B.bag ~dict ~data:(filter0 data f )

let partition f m =
let partition m f =
let mdata, dict = B.(data m, dict m) in
let l,r = partition0 f mdata in
let l,r = partition0 mdata f in
B.bag ~data:l ~dict, B.bag ~data:r ~dict

let length m = length0 (B.data m)

let elements m = elements0 (B.data m)
let toList m = toList0 (B.data m)
let toArray m = toArray0 (B.data m)
let min m = min0 (B.data m)

let max m = max0 (B.data m)
let minOpt m = minOpt0 (B.data m)
let maxOpt m = maxOpt0 (B.data m)

let split (type elt) (type id) e (m : (elt,id) t) =
let dict, data = B.(dict m, data m) in
Expand Down
47 changes: 19 additions & 28 deletions jscomp/others/bs_Set.mli
Original file line number Diff line number Diff line change
Expand Up @@ -97,34 +97,34 @@ val subset:
(** [subset s1 s2] tests whether the set [s1] is a subset of
the set [s2]. *)

val iter0: ('elt -> unit [@bs]) -> ('elt, 'id) t0 -> unit
val iter: ('elt -> unit [@bs]) -> ('elt, 'id) t -> unit
val iter0: ('elt, 'id) t0 -> ('elt -> unit [@bs]) -> unit
val iter: ('elt, 'id) t -> ('elt -> unit [@bs]) -> unit
(** [iter f s] applies [f] in turn to all elements of [s].
The elements of [s] are presented to [f] in increasing order
with respect to the ordering over the type of the elements. *)

val fold0: ('elt -> 'a -> 'a [@bs]) -> ('elt, 'id) t0 -> 'a -> 'a
val fold: ('elt -> 'a -> 'a [@bs]) -> ('elt, 'id) t -> 'a -> 'a
val fold0: ('elt, 'id) t0 -> 'a -> ('a -> 'elt -> 'a [@bs]) -> 'a
val fold: ('elt, 'id) t -> 'a -> ('a -> 'elt -> 'a [@bs]) -> 'a
(** [fold f s a] computes [(f xN ... (f x2 (f x1 a))...)],
where [x1 ... xN] are the elements of [s], in increasing order. *)

val forAll0: ('elt -> bool [@bs]) -> ('elt, 'id) t0 -> bool
val forAll:('elt -> bool [@bs]) -> ('elt, 'id) t -> bool
val forAll0: ('elt, 'id) t0 -> ('elt -> bool [@bs]) -> bool
val forAll: ('elt, 'id) t -> ('elt -> bool [@bs]) -> bool
(** [for_all p s] checks if all elements of the set
satisfy the predicate [p]. *)

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

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

val partition0: ('elt -> bool [@bs]) -> ('elt, 'id) t0 -> ('elt, 'id) t0 * ('elt, 'id) t0
val partition: ('elt -> bool [@bs]) -> ('elt, 'id) t -> ('elt, 'id) t * ('elt, 'id) t
val partition0: ('elt, 'id) t0 -> ('elt -> bool [@bs]) -> ('elt, 'id) t0 * ('elt, 'id) t0
val partition: ('elt, 'id) t -> ('elt -> bool [@bs]) -> ('elt, 'id) t * ('elt, '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
Expand All @@ -134,25 +134,16 @@ val length0: ('elt, 'id) t0 -> int
val length: ('elt, 'id) t -> int
(** Return the number of elements of a set. *)

val elements0: ('elt, 'id) t0 -> 'elt list
val elements: ('elt, 'id) t -> 'elt list
(** Return the list of all elements of the given set.
The returned list is sorted in increasing order with respect
to the ordering [Ord.compare], where [Ord] is the argument
given to {!Set.Make}. *)
val toList0: ('elt, 'id) t0 -> 'elt list
val toList: ('elt, 'id) t -> 'elt list
(** In increasing order*)
val toArray0: ('elt, 'id) t0 -> 'elt array
val toArray: ('elt, 'id) t -> 'elt array

val min0: ('elt, 'id) t0 -> 'elt option
val min: ('elt, 'id) t -> 'elt option
(** Return the smallest element of the given set
(with respect to the [Ord.compare] ordering), or raise
[Not_found] if the set is empty. *)

val max0: ('elt, 'id) t0 -> 'elt option
val max: ('elt, 'id) t -> 'elt option
(** Same as {!Set.S.min_elt}, but returns the largest element of the
given set. *)
val minOpt0: ('elt, 'id) t0 -> 'elt option
val minOpt: ('elt, 'id) t -> 'elt option
val maxOpt0: ('elt, 'id) t0 -> 'elt option
val maxOpt: ('elt, 'id) t -> 'elt option


val split0:
Expand Down
8 changes: 5 additions & 3 deletions jscomp/others/bs_SetInt.ml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,18 @@ type t = I.t
let empty = N.empty0
let isEmpty = N.isEmpty0
let singleton = N.singleton0
let min = N.min0
let max = N.max0
let minOpt = N.minOpt0
let minNull = N.minNull0
let maxOpt = N.maxOpt0
let maxNull = N.maxNull0
let iter = N.iter0
let fold = N.fold0
let forAll = N.forAll0
let exists = N.exists0
let filter = N.filter0
let partition = N.partition0
let length = N.length0
let elements = N.elements0
let toList = N.toList0
let toArray = N.toArray0
let checkInvariant = N.checkInvariant

Expand Down
57 changes: 22 additions & 35 deletions jscomp/others/bs_SetInt.mli
Original file line number Diff line number Diff line change
Expand Up @@ -8,91 +8,81 @@ type t
(** The type of sets. *)

val empty: t
(** The empty set. *)


val isEmpty: t -> bool
(** Test whether a set is empty or not. *)

val mem: t -> elt -> bool
(** [mem x s] tests whether [x] belongs to the set [s]. *)


val add: t -> elt -> t
(** [add x s] returns a set containing all elements of [s],
plus [x]. If [x] was already in [s], [s] is returned unchanged. *)
(** If [x] was already in [s], [s] is returned unchanged. *)

val singleton: elt -> t
(** [singleton x] returns the one-element set containing only [x]. *)

val remove: t -> elt -> t
(** [remove x s] returns a set containing all elements of [s],
except [x]. If [x] was not in [s], [s] is returned unchanged. *)
(** If [x] was not in [s], [s] is returned unchanged. *)

val union: t -> t -> t
(** Set union. *)

val inter: t -> t -> t
(** Set intersection. *)

val diff: t -> t -> t
(** Set difference. *)


val cmp: t -> t -> int
(** Total ordering between sets. Can be used as the ordering function
for doing sets of sets. *)

val eq: t -> t -> bool
(** [equal s1 s2] tests whether the sets [s1] and [s2] are
(** [eq s1 s2] tests whether the sets [s1] and [s2] are
equal, that is, contain equal elements. *)

val subset: t -> t -> bool
(** [subset s1 s2] tests whether the set [s1] is a subset of
the set [s2]. *)

val iter: (elt -> unit [@bs]) -> t -> unit
val iter: t -> (elt -> unit [@bs]) -> unit
(** [iter f s] applies [f] in turn to all elements of [s].
The elements of [s] are presented to [f] in increasing order
with respect to the ordering over the type of the elements. *)

val fold: (elt -> 'a -> 'a [@bs]) -> t -> 'a -> 'a
(** [fold f s a] computes [(f xN ... (f x2 (f x1 a))...)],
where [x1 ... xN] are the elements of [s], in increasing order. *)
val fold: t -> 'a -> ('a -> elt -> 'a [@bs]) -> 'a
(** Iterate in increasing order. *)

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

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

val filter: (elt -> bool [@bs]) -> t -> t
val filter: t -> (elt -> bool [@bs]) -> t
(** [filter p s] returns the set of all elements in [s]
that satisfy predicate [p]. *)

val partition: (elt -> bool [@bs]) -> t -> t * t
val partition: t -> (elt -> bool [@bs]) -> t * 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 length: t -> int

val elements: t -> elt list
val toList: t -> elt list
(** Return the list of all elements of the given set.
The returned list is sorted in increasing order with respect
to the ordering [Ord.compare], where [Ord] is the argument
given to {!Set.Make}. *)

val toArray: t -> elt array

val min: t -> elt option
(** Return the smallest element of the given set
(with respect to the [Ord.compare] ordering), or raise
[Not_found] if the set is empty. *)

val max: t -> elt option
(** Same as {!Set.S.min_elt}, but returns the largest element of the
given set. *)
val minOpt: t -> elt option
val minNull: t -> elt Js.null
val maxOpt: t -> elt option
val maxNull: t -> elt Js.null


val split: elt -> t -> t * bool * t
Expand All @@ -105,11 +95,8 @@ val split: elt -> t -> t * bool * t
or [true] if [s] contains an element equal to [x]. *)

val findOpt: elt -> t -> elt option
(** [find x s] returns the element of [s] equal to [x] (according
to [Ord.compare]), or raise [Not_found] if no such element
exists.
@since 4.01.0 *)


val ofArray : elt array -> t

val checkInvariant : t -> bool
val checkInvariant : t -> bool
6 changes: 3 additions & 3 deletions jscomp/others/bs_SetIntM.ml
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ let empty = N.empty0
(* No value restriction ? *)
let isEmpty = N.isEmpty0
let singleton = N.singleton0
let min = N.min0
let max = N.max0
let minOpt = N.minOpt0
let maxOpt = N.maxOpt0
let iter = N.iter0
let fold = N.fold0
let forAll = N.forAll0
let exists = N.exists0
let filter = N.filter0
let partition = N.partition0
let length = N.length0
let elements = N.elements0
let toList = N.toList0
let toArray = N.toArray0
let checkInvariant = N.checkInvariant

Expand Down
8 changes: 5 additions & 3 deletions jscomp/others/bs_SetString.ml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,18 @@ type t = I.t
let empty = N.empty0
let isEmpty = N.isEmpty0
let singleton = N.singleton0
let min = N.min0
let max = N.max0
let minOpt = N.minOpt0
let maxOpt = N.maxOpt0
let minNull = N.minNull0
let maxNull = N.maxNull0
let iter = N.iter0
let fold = N.fold0
let forAll = N.forAll0
let exists = N.exists0
let filter = N.filter0
let partition = N.partition0
let length = N.length0
let elements = N.elements0
let toList = N.toList0
let toArray = N.toArray0
let checkInvariant = N.checkInvariant

Expand Down

0 comments on commit 5e87199

Please sign in to comment.