+ let contains t s =
+ Array.fold_left (fun a i -> DocIdSet.add i a) DocIdSet.empty (Text.contains t.doc s)
+
+
+ let contains_old t s =
+ let regexp = Str.regexp_string s in
+ let matching arg =
+ try
+ let _ = Str.search_forward regexp arg 0;
+ in true
+ with _ -> false
+ in
+ let rec find t acc = match t.node with
+ | Nil -> acc
+ | String i ->
+ if matching (string t) then DocIdSet.add i acc else acc
+ | Node(_) -> (find (left t )) ((find (right t)) acc)
+ in
+ find t DocIdSet.empty
+
+
+ let contains_iter t s =
+ let regexp = Str.regexp_string s in
+ let matching arg =
+ try
+ let _ = Str.search_forward regexp arg 0;
+ in true
+ with _ -> false
+ in
+ let size = Text.size t.doc in
+ let rec find acc n =
+ if n == size then acc
+ else
+ find
+ (if matching (Text.get_cached_text t.doc (Obj.magic n)) then
+ DocIdSet.add (Obj.magic n) acc
+ else acc) (n+1)
+ in
+ find DocIdSet.empty 0
+
+
+
+
+ let count_contains t s = Text.count_contains t.doc s
+*)
+
+ let count t s = text_count t.doc s
+(*
+ let is_left t =
+ if is_root t then false
+ else
+ if tag (parent t) == Tag.pcdata then false
+ else
+ let u = left (parent t) in
+ (id t) == (id u)
+*)
+ let print_xml_fast outc t =
+ let rec loop ?(print_right=true) t =
+ match t.node with
+ | Nil -> ()
+ | Text(i,n) -> output_string outc (text_get_text t.doc i);
+ if print_right
+ then loop (right t)
+ | Node (n) ->
+ let tg = Tag.to_string (tag t) in
+ let l = left t
+ and r = right t
+ in
+ output_char outc '<';
+ output_string outc tg;
+ ( match l.node with
+ Nil -> output_string outc "/>"
+ | Node(_) when Tag.equal (tag l) Tag.attribute ->
+ (loop_attributes (left l);
+ match (right l).node with
+ | Nil -> output_string outc "/>"
+ | _ ->
+ output_char outc '>';
+ loop (right l);
+ output_string outc "</";
+ output_string outc tg;
+ output_char outc '>' )
+ | _ ->
+ output_char outc '>';
+ loop l;
+ output_string outc "</";
+ output_string outc tg;
+ output_char outc '>'
+ );if print_right then loop r
+ and loop_attributes a =