-
Notifications
You must be signed in to change notification settings - Fork 441
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
30 changed files
with
1,671 additions
and
543 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
Oops, something went wrong.