Skip to content

Commit

Permalink
Merge adb5668 into 656c2d9
Browse files Browse the repository at this point in the history
  • Loading branch information
bobzhang committed Jan 2, 2018
2 parents 656c2d9 + adb5668 commit afd1d83
Show file tree
Hide file tree
Showing 30 changed files with 1,671 additions and 543 deletions.
3 changes: 3 additions & 0 deletions jscomp/others/.depend
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ bs_SetInt.cmj : bs_internalSetInt.cmj bs_internalAVLset.cmj bs_SetInt.cmi
bs_SetIntM.cmj : bs_internalSetInt.cmj bs_internalAVLset.cmj bs_SetIntM.cmi
bs_SetString.cmj : bs_internalSetString.cmj bs_internalAVLset.cmj \
bs_SetString.cmi
bs_SetStringM.cmj : bs_internalSetString.cmj bs_internalAVLset.cmj \
bs_SetStringM.cmi
node_child_process.cmj : node.cmj
js_boolean.cmj : js_boolean.cmi
js_math.cmj :
Expand Down Expand Up @@ -93,6 +95,7 @@ bs_MapInt.cmi :
bs_SetInt.cmi :
bs_SetIntM.cmi :
bs_SetString.cmi :
bs_SetStringM.cmi :
js_boolean.cmi :
js_dict.cmi :
js_cast.cmi :
Expand Down
28 changes: 25 additions & 3 deletions jscomp/others/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ SOURCE_LIST= node_path node_fs node_process dict node_module js_array js_string
bs_SetInt\
bs_SetIntM\
bs_SetString\
bs_SetStringM\
node_child_process js_boolean js_math\
js_dict js_date js_global js_cast js_promise\
dom dom_storage\
Expand Down Expand Up @@ -71,6 +72,12 @@ clean::
rm -f *~
rm -f *.annot
rm -f *.rawlambda *.lam *.lambda *.map
rm -rf bs_HashSetString.ml bs_HashSetString.mli bs_HashSetInt.ml bs_HashSetInt.mli \
bs_HashMapInt.ml bs_HashMapInt.mli bs_HashMapString.ml bs_HashMapString.mli \
bs_MapInt.ml bs_MapInt.mli bs_MapString.ml bs_MapString.mli \
bs_internalSetInt.ml bs_internalSetString.ml \
bs_SetInt.ml bs_SetInt.mli bs_SetString.ml bs_SetString.mli \
bs_SetIntM.ml bs_SetIntM.mli bs_SetStringM.ml bs_SetStringM.mli

ifndef BS_RELEASE_BUILD
bs_HashSetString.ml: hashset.cppo.ml
Expand All @@ -97,14 +104,29 @@ bs_MapString.mli: map.cppo.mli
cppo -D TYPE_STRING $^ > $@
bs_MapInt.mli: map.cppo.mli
cppo -D TYPE_INT $^ > $@
bs_internalSetInt.ml: set.cppo.ml
bs_internalSetInt.ml: internal_set.cppo.ml
cppo -D TYPE_INT $^ > $@
bs_SetInt.mli: set.cppo.mli
bs_internalSetString.ml: internal_set.cppo.ml
cppo -D TYPE_STRING $^ > $@

bs_SetInt.ml: set.cppo.ml
cppo -D TYPE_INT $^ > $@
bs_internalSetString.ml: set.cppo.ml
bs_SetString.ml: set.cppo.ml
cppo -D TYPE_STRING $^ > $@

bs_SetInt.mli: set.cppo.mli
cppo -D TYPE_INT $^ > $@
bs_SetString.mli: set.cppo.mli
cppo -D TYPE_STRING $^ > $@

bs_SetIntM.ml: setm.cppo.ml
cppo -D TYPE_INT $^ > $@
bs_SetStringM.ml: setm.cppo.ml
cppo -D TYPE_STRING $^ > $@
bs_SetIntM.mli: setm.cppo.mli
cppo -D TYPE_INT $^ > $@
bs_SetStringM.mli: setm.cppo.mli
cppo -D TYPE_STRING $^ > $@
endif


Expand Down
5 changes: 4 additions & 1 deletion jscomp/others/bs_SetInt.ml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
module N = Bs_internalAVLset
# 2 "set.cppo.ml"
module I = Bs_internalSetInt
# 8
module N = Bs_internalAVLset


type elt = I.elt
type t = I.t
Expand Down
34 changes: 8 additions & 26 deletions jscomp/others/bs_SetInt.mli
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,18 @@ type t
(** The type of sets. *)

val empty: t


val isEmpty: t -> bool

val mem: t -> elt -> bool


val add: t -> elt -> t
(** 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
(** If [x] was not in [s], [s] is returned unchanged. *)

val union: t -> t -> t

val inter: t -> t -> t

val diff: t -> t -> t


val cmp: t -> t -> int
(** Total ordering between sets. Can be used as the ordering function
for doing sets of sets. *)
Expand All @@ -44,9 +33,7 @@ val subset: t -> t -> bool
the set [s2]. *)

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. *)
(** In increasing order*)

val fold: t -> 'a -> ('a -> elt -> 'a [@bs]) -> 'a
(** Iterate in increasing order. *)
Expand All @@ -70,22 +57,17 @@ val partition: t -> (elt -> bool [@bs]) -> t * t
[s] that do not satisfy [p]. *)

val length: t -> int

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

(** In increasing order with respect *)
val toArray: t -> elt array
val ofArray: elt array -> t
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
val split: t -> elt -> t * bool * t
(** [split x s] returns a triple [(l, present, r)], where
[l] is the set of elements of [s] that are
strictly less than [x];
Expand All @@ -94,9 +76,9 @@ val split: elt -> t -> t * bool * t
[present] is [false] if [s] contains no element equal to [x],
or [true] if [s] contains an element equal to [x]. *)

val findOpt: elt -> t -> elt option
val findOpt: t -> elt -> elt option



val ofArray : elt array -> t

val checkInvariant : t -> bool
val checkInvariant: t -> bool
134 changes: 97 additions & 37 deletions jscomp/others/bs_SetIntM.ml
Original file line number Diff line number Diff line change
@@ -1,42 +1,102 @@
# 2 "setm.cppo.ml"
module I = Bs_internalSetInt
# 8
module N = Bs_internalAVLset


module N = Bs_internalAVLset
type elt = I.elt


module I = Bs_internalSetInt
type t = {
mutable root : I.t
} [@@bs.deriving abstract]

type elt = I.elt
type t = I.t


let empty = N.empty0
(* No value restriction ? *)
let isEmpty = N.isEmpty0
let singleton = N.singleton0
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 toList = N.toList0
let toArray = N.toArray0
let checkInvariant = N.checkInvariant

let add = I.addMutate
let addArray = I.addArrayMutate

let remove = I.removeMutate
let ofArray = I.ofArray
let cmp = I.cmp
let diff = I.diff
let eq = I.eq
let findOpt = I.findOpt
let split = I.split
let subset = I.subset
let inter = I.inter
let union = I.union
let mem = I.mem
let empty () = t ~root:N.empty0
let isEmpty d =
N.isEmpty0 (root d)
let singleton x =
t ~root:(N.singleton0 x)
let minOpt d =
N.minOpt0 (root d)
let minNull d =
N.minNull0 (root d)
let maxOpt d =
N.maxOpt0 (root d)
let maxNull d =
N.maxNull0 (root d)
let iter d f =
N.iter0 (root d) f
let fold d acc cb =
N.fold0 (root d) acc cb
let forAll d p =
N.forAll0 (root d) p
let exists d p =
N.exists0 (root d) p
let filter d p =
t ~root:(N.filter0 (root d) p )
let partition d p =
let a , b = N.partition0 (root d) p in
t ~root:a, t ~root:b
let length d =
N.length0 (root d)
let toList d =
N.toList0 (root d)
let toArray d =
N.toArray0 (root d)
let checkInvariant d =
N.checkInvariant (root d)

let add d k =
let old_root = root d in
let v = I.addMutate old_root k in
if v != old_root then
rootSet d v ;
d
let addOnly d k =
let old_root = root d in
let v = I.addMutate old_root k in
if v != old_root then
rootSet d v

let addArrayOnly d arr =
let old_root = root d in
let v = I.addArrayMutate old_root arr in
if v != old_root then
rootSet d v

let addArray d arr =
let old_root = root d in
let v = I.addArrayMutate old_root arr in
if v != old_root then
rootSet d v ;
d

let remove d v =
let old_root = root d in
let v = I.removeMutate old_root v in
if v != old_root then
rootSet d v ;
d
let removeOnly d v =
let old_root = root d in
let v = I.removeMutate old_root v in
if v != old_root then
rootSet d v

let ofArray xs =
t ~root:(I.ofArray xs)
let cmp d0 d1 =
I.cmp (root d0) (root d1)
let diff d0 d1 =
t ~root:(I.diff (root d0) (root d1))
let eq d0 d1 =
I.eq (root d0) (root d1)
let findOpt d x =
I.findOpt (root d) x
let split d p =
let a,b,c = I.split (root d) p in
t ~root:a, b, t ~root:c
let subset a b = I.subset (root a) (root b)
let inter a b = t ~root:(I.inter (root a) (root b))
let union a b = t ~root:(I.union (root a) (root b))
let mem d x = I.mem (root d) x
67 changes: 54 additions & 13 deletions jscomp/others/bs_SetIntM.mli
Original file line number Diff line number Diff line change
@@ -1,23 +1,64 @@
# 4 "setm.cppo.mli"
type elt = int

# 9
type t
type elt = int
val empty: unit -> t
val isEmpty: t -> bool
val mem: t -> elt -> bool
val add: t -> elt -> t
val addOnly: t -> elt -> unit
val singleton: elt -> t
val remove: t -> elt -> t
val removeOnly: t -> elt -> unit
val union: t -> t -> t
val inter: t -> t -> t
val diff: t -> t -> t
val cmp: t -> t -> int
val eq: t -> t -> bool

val empty: t
val subset: t -> t -> bool

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

val isEmpty: t -> bool
(** Test whether a set is empty or not. *)
val fold: t -> 'a -> ('a -> elt -> 'a [@bs]) -> 'a
(** Iterate in increasing order. *)

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

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

val add: t -> elt -> t
val remove : t -> elt -> t
val addArray : t -> elt array -> t
val ofArray : elt array -> t
val toArray : t -> elt array
val singleton: elt -> t
(** [singleton x] returns the one-element set containing only [x]. *)
val filter: t -> (elt -> bool [@bs]) -> t
(** [filter p s] returns the set of all elements in [s]
that satisfy predicate [p]. *)

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 toList : t -> elt list
(** In increasing order with respect *)
val toArray: t -> elt array
val ofArray: elt array -> t
val minOpt: t -> elt option
val minNull: t -> elt Js.null
val maxOpt: t -> elt option
val maxNull: t -> elt Js.null

val split: t -> elt -> t * bool * t
val findOpt: t -> elt -> elt option

val addArray: t -> elt array -> t
val addArrayOnly: t -> elt array -> unit

val checkInvariant: t -> bool

val length : t -> int

Loading

0 comments on commit afd1d83

Please sign in to comment.