X-Git-Url: http://git.nguyen.vg/gitweb/?a=blobdiff_plain;f=src%2Fcache.ml;h=68cae6760c9cf2cf6f6f2371004130a8043640f8;hb=7c4c61cec6fe1ae3a1b83a59b17ce90adcfe9b0b;hp=3efe3dcde325bffb73eb0fa97a9db9385d5ab4b1;hpb=9d761fb9aba3c653b1666e7ea3a5d2aec9a1138a;p=SXSI%2Fxpathcomp.git diff --git a/src/cache.ml b/src/cache.ml index 3efe3dc..68cae67 100644 --- a/src/cache.ml +++ b/src/cache.ml @@ -1,4 +1,3 @@ -INCLUDE "trace.ml" let realloc l old_size new_size dummy = let l' = Array.create new_size dummy in @@ -20,6 +19,14 @@ struct } + let print fmt a = + Format.fprintf fmt "{ offset=%i;\n dummy=_;line=%a \n}\n%!" + a.offset + (Pretty.print_array ~sep:", " (fun fmt x -> + if x==a.dummy then + Format.fprintf fmt "%s" "D" + else + Format.fprintf fmt "%s" "E")) a.line let add a i v = if a.offset == ~-1 then a.offset <- i; @@ -45,7 +52,7 @@ struct for j = 0 to len - 1 do narray.(j) <- a.line.(j); done; - narray.(i - offset + 1) <- v; + narray.(i - offset) <- v; a.line <- narray end @@ -84,12 +91,13 @@ struct let add a i j v = let line = Lvl1.find a i in if line == a.Lvl1.dummy then - let nline = { line with Lvl1.offset = ~-1 } in - Lvl1.add nline j v; - Lvl1.add a i nline + let nline = Lvl1.create 0 line.Lvl1.dummy in + Lvl1.add a i nline; + Lvl1.add nline j v else Lvl1.add line j v + let find a i j = let v = Lvl1.find a i in if v == a.Lvl1.dummy then a.Lvl1.dummy.Lvl1.dummy @@ -113,7 +121,7 @@ struct type 'a t = 'a Lvl2.t Lvl1.t let create n a = - let dummy1 = Lvl2.create 0 a in + let dummy1 = Lvl2.create 512 a in { Lvl1.line = Array.create n dummy1; Lvl1.offset = ~-1; Lvl1.dummy = dummy1;