cherry pick from local- branch
[SXSI/xpathcomp.git] / tree.mli
index fd7bad7..539103c 100644 (file)
--- a/tree.mli
+++ b/tree.mli
-(******************************************************************************)
-(*  SXSI : XPath evaluator                                                    *)
-(*  Kim Nguyen (Kim.Nguyen@nicta.com.au)                                      *)
-(*  Copyright NICTA 2008                                                      *)
-(*  Distributed under the terms of the LGPL (see LICENCE)                     *)
-(******************************************************************************)
-module type BINARY =
-sig
-  type node_content
-  type string_content
-  type descr = Nil| Node of node_content | String of string_content 
-  type t
-  val parse_xml_uri : string -> t
-  val parse_xml_string : string -> t
-  val string : t -> string
-  val descr : t -> descr
-  val left : t -> t
-  val right : t -> t
-  val parent : t -> t
-  val id : t -> int
-  val tag : t -> Tag.t
-  val print_xml_fast : out_channel -> t -> unit
-  val compare : t -> t -> int
-  val equal : t -> t -> bool
-  module DocIdSet : Set.S with type elt = string_content
-  val string_below : t -> string_content -> bool
-  val contains : t -> string -> DocIdSet.t
-  val contains_old : t -> string -> bool
-  val dump : t -> unit 
-end
-
-module Binary : BINARY
-
-module DEBUGTREE : sig
-  include BINARY
-  val print_stats : Format.formatter -> unit
-end
+type t 
+
+val init_textfun : [ `CONTAINS | `STARTSWITH | `ENDSWITH | `EQUALS ] -> t -> string -> unit
+val init_naive_contains : t -> string -> unit
+
+
+val parse_xml_uri : string -> t
+val parse_xml_string : string -> t
+val save : t -> string -> unit
+val load : ?sample:int -> ?load_text:bool -> string -> t
+val tag_pool : t -> Tag.pool
+
+
+type 'a node
+type node_kind = [ `Tree | `Text ]
+val equal : [ `Tree ] node -> [ `Tree ] node -> bool
+val compare : [ `Tree ] node -> [ `Tree ] node -> int
+val dump_node : 'a node -> string
+
+
+val nil : [ `Tree ] node
+val root : [ `Tree ] node
+val size : t -> int
+val is_root : [ `Tree ] node -> bool
+val is_nil : [ `Tree ] node -> bool
+
+val parent : t -> [ `Tree ] node -> [ `Tree ] node
+val first_child : t -> [ `Tree ] node -> [ `Tree ] node
+val first_element : t -> [ `Tree ] node -> [ `Tree ] node
+val tagged_child : t -> Tag.t -> [ `Tree ] node -> [ `Tree ] node
+
+val select_child : t -> Ptset.Int.t -> [ `Tree ] node -> [ `Tree ] node
+
+val next_sibling : t -> [ `Tree ] node -> [ `Tree ] node
+val next_element : t -> [ `Tree ] node -> [ `Tree ] node
+
+val next_sibling_below : t -> [ `Tree ] node -> [ `Tree ] node ->  [ `Tree ] node
+val next_element_below : t -> [ `Tree ] node -> [ `Tree ] node ->  [ `Tree ] node
+
+val tagged_following_sibling : t ->  Tag.t ->  [ `Tree ] node -> [ `Tree ] node
+val tagged_following_sibling_below : t -> Tag.t -> [ `Tree ] node -> [ `Tree ] node -> [ `Tree ] node
+
+val select_following_sibling : t -> Ptset.Int.t -> [ `Tree ] node -> [ `Tree ] node
+val select_following_sibling_below : t -> Ptset.Int.t -> [ `Tree ] node -> [ `Tree ] node -> [ `Tree ] node 
+
+
+
+val tag : t -> [ `Tree ] node -> Tag.t
+val id : t -> [ `Tree ] node -> int
+
+val tagged_descendant : t -> Tag.t -> [ `Tree ] node -> [`Tree] node
+val select_descendant : t -> Ptset.Int.t -> [ `Tree ] node -> [`Tree] node
+
+val tagged_following_below : t -> Tag.t ->  [ `Tree ] node -> [`Tree] node -> [ `Tree ] node
+val select_following_below : t -> Ptset.Int.t ->  [ `Tree ] node -> [`Tree] node -> [ `Tree ] node
+
+val count : t -> string -> int
+val print_xml_fast : out_channel -> t -> [ `Tree ] node -> unit
+val print_xml_fast2 : out_channel -> t -> [ `Tree ] node -> unit
+val print_xml_fast3 : t -> [ `Tree ] node -> Unix.file_descr -> unit
+
+val tags_children : t -> Tag.t -> Ptset.Int.t
+val tags_below : t -> Tag.t -> Ptset.Int.t
+val tags_siblings : t -> Tag.t -> Ptset.Int.t
+val tags_after : t -> Tag.t -> Ptset.Int.t
+val tags : t ->  Tag.t  -> Ptset.Int.t*Ptset.Int.t*Ptset.Int.t*Ptset.Int.t
+val is_below_right : t ->  [`Tree] node ->  [`Tree] node -> bool
+val is_binary_ancestor : t ->  [`Tree] node ->  [`Tree] node -> bool
+val is_left : t ->  [`Tree] node -> bool
+
+val binary_parent : t ->  [`Tree] node -> [`Tree] node 
+
+val count_contains : t -> string -> int
+(* val unsorted_contains : t -> string -> unit *)
+val text_size : t -> int
+val doc_ids : t ->  [`Tree] node ->  [`Text] node *  [`Text] node 
+val subtree_tags : t -> Tag.t ->  [`Tree] node -> int
+val get_text : t -> [`Tree] node ->  string
+val get_text_id : t -> [`Tree] node ->  [`Text ] node
+
+val dump_tree : Format.formatter -> t -> unit
+val subtree_size : t -> [`Tree] node -> int
+val subtree_elements : t -> [`Tree] node -> int
+val text_below : t -> [`Tree] node -> [`Tree] node
+val text_next :  t -> [`Tree] node -> [`Tree] node -> [`Tree] node 
+
+val closing : t -> [`Tree] node -> [`Tree] node
+val is_open : t -> [`Tree] node -> bool
+
+val benchmark_jump : t -> Tag.t -> unit
+val benchmark_fcns : t -> int
+val benchmark_fene : t -> int
+val benchmark_lcps : t -> unit
+val benchmark_iter : t -> int
+val stats : t -> unit
+
+val test_suffix : t -> string -> int
+val test_prefix : t -> string -> int
+val test_equals : t -> string -> int
+val test_contains : t -> string -> int