Skip to content

Commit

Permalink
Merge 83d23e7 into 009f726
Browse files Browse the repository at this point in the history
  • Loading branch information
bobzhang committed Dec 30, 2017
2 parents 009f726 + 83d23e7 commit ea070ff
Show file tree
Hide file tree
Showing 21 changed files with 193 additions and 203 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
20 changes: 10 additions & 10 deletions jscomp/others/bs_Set.ml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ 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,26 +268,26 @@ 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)

Expand Down
28 changes: 14 additions & 14 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,8 +134,8 @@ 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
val toList0: ('elt, 'id) t0 -> 'elt list
val toList: ('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
Expand Down
2 changes: 1 addition & 1 deletion jscomp/others/bs_SetInt.ml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ 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
47 changes: 18 additions & 29 deletions jscomp/others/bs_SetInt.mli
Original file line number Diff line number Diff line change
Expand Up @@ -8,76 +8,71 @@ 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
val fold: 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 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
Expand All @@ -87,12 +82,9 @@ 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. *)
(with respect to the [Ord.compare] ordering) *)

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


val split: elt -> t -> t * bool * t
Expand All @@ -105,11 +97,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
2 changes: 1 addition & 1 deletion jscomp/others/bs_SetIntM.ml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ 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
2 changes: 1 addition & 1 deletion jscomp/others/bs_SetString.ml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ 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
47 changes: 18 additions & 29 deletions jscomp/others/bs_SetString.mli
Original file line number Diff line number Diff line change
Expand Up @@ -8,76 +8,71 @@ 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
val fold: 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 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
Expand All @@ -87,12 +82,9 @@ 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. *)
(with respect to the [Ord.compare] ordering) *)

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


val split: elt -> t -> t * bool * t
Expand All @@ -105,11 +97,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
Loading

0 comments on commit ea070ff

Please sign in to comment.