(***********************************************************************)
(*
- Time-stamp: <Last modified on 2013-03-13 18:27:13 CET by Kim Nguyen>
+ Time-stamp: <Last modified on 2013-03-13 18:54:08 CET by Kim Nguyen>
*)
INCLUDE "utils.ml"
end
= struct
- type cache = (int, StateSet.t) Hashtbl.t
- let get c t n =
- try Hashtbl.find c (T.preorder t n)
- with Not_found -> StateSet.empty
+ type cache = StateSet.t Cache.N1.t
+ let get c t n = Cache.N1.find c (T.preorder t n)
- let set c t n v = Hashtbl.replace c (T.preorder t n) v
+ let set c t n v = Cache.N1.add c (T.preorder t n) v
module Info = struct
type t = { is_left : bool;
(acct, StateSet.add q accs)
else
(Ata.TransList.cons trs acct, accs)
- ) ltrs (Ata.TransList.nil, ss)
+ ) ltrs (Ata.TransList.nil, ss)
in
Cache.N6.add cache i j k l m n res; res
else
loop node []
let eval auto tree node =
- let cache = Hashtbl.create 511 in
+ let cache = Cache.N1.create (T.size tree) StateSet.empty in
let redo = ref true in
let iter = ref 0 in
while !redo do
(***********************************************************************)
(*
- Time-stamp: <Last modified on 2013-03-13 10:33:17 CET by Kim Nguyen>
+ Time-stamp: <Last modified on 2013-03-13 18:47:18 CET by Kim Nguyen>
*)
open Utils
type t = {
root : node;
+ size : int;
(* TODO add other intersting stuff *)
}
match ctx.stack with
[ root ] ->
root.next_sibling <- nil;
- { root = root }
+ { root = root;
+ size = ctx.current_preorder
+ }
| _ -> raise (Expat.Expat_error Expat.UNCLOSED_TOKEN)
)
let nnode = { node with next_sibling = nil } in print_xml out tree_ nnode
let root t = t.root
+let size t = t.size
let first_child _ n = n.first_child
let next_sibling _ n = n.next_sibling
let parent _ n = n.parent
(***********************************************************************)
(*
- Time-stamp: <Last modified on 2013-03-11 00:12:27 CET by Kim Nguyen>
+ Time-stamp: <Last modified on 2013-03-13 18:46:18 CET by Kim Nguyen>
*)
(** Implementation of documents as binary trees *)
type t
(** The type of trees *)
+ val size : t -> int
+ (** Return the number of nodes *)
+
val nil : node
(** Nil node, denoting the first/second child of a leaf or the parent of
the root *)