projects
/
SXSI
/
xpathcomp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Refresh the installation procedure.
[SXSI/xpathcomp.git]
/
src
/
hlist.ml
diff --git
a/src/hlist.ml
b/src/hlist.ml
index
300c6a1
..
aa3781f
100644
(file)
--- a/
src/hlist.ml
+++ b/
src/hlist.ml
@@
-18,7
+18,7
@@
module type S = sig
val equal : t -> t -> bool
val nil : t
val node : t -> t node
val equal : t -> t -> bool
val nil : t
val node : t -> t node
- val cons : elt -> t -> t
+ val cons :
?sorted:bool ->
elt -> t -> t
val hd : t -> elt
val tl : t -> t
val fold : (elt -> 'a -> 'a) -> t -> 'a -> 'a
val hd : t -> elt
val tl : t -> t
val fold : (elt -> 'a -> 'a) -> t -> 'a -> 'a
@@
-28,7
+28,8
@@
module type S = sig
val rev_map : (elt -> elt) -> t -> t
val length : t -> int
val mem : elt -> t -> bool
val rev_map : (elt -> elt) -> t -> t
val length : t -> int
val mem : elt -> t -> bool
-
+ val stats : unit -> unit
+ val init : unit -> unit
end
module Make (H : Hcons.SA) : S with type elt = H.t =
end
module Make (H : Hcons.SA) : S with type elt = H.t =
@@
-56,15
+57,22
@@
struct
let equal = Node.equal
let uid x= x.Node.id
let nil = Node.make Nil
let equal = Node.equal
let uid x= x.Node.id
let nil = Node.make Nil
-
+ let stats = Node.stats
+ let init = Node.init
(* doing sorted insertion allows to make better use of hash consing *)
(* doing sorted insertion allows to make better use of hash consing *)
- let rec cons e l =
+ let rec
sorted_
cons e l =
match l.Node.node with
| Nil -> Node.make (Cons(e, l))
| Cons (x, ll) ->
if H.uid e < H.uid x
then Node.make (Cons(e, l))
match l.Node.node with
| Nil -> Node.make (Cons(e, l))
| Cons (x, ll) ->
if H.uid e < H.uid x
then Node.make (Cons(e, l))
- else Node.make (Cons(x, cons e ll))
+ else Node.make (Cons(x, sorted_cons e ll))
+
+ let cons e l =
+ Node.make(Cons(e, l))
+
+ let cons ?(sorted=true) e l =
+ if sorted then sorted_cons e l else cons e l
let hd = function { Node.node = Cons(a,_) } -> a | _ -> failwith "hd"
let tl = function { Node.node = Cons(_,a) } -> a | _ -> failwith "tl"
let hd = function { Node.node = Cons(a,_) } -> a | _ -> failwith "hd"
let tl = function { Node.node = Cons(_,a) } -> a | _ -> failwith "tl"