X-Git-Url: http://git.nguyen.vg/gitweb/?a=blobdiff_plain;f=XMLTree.h;h=1268cb6b015c369e0bfdc87f7425879d8b88cc47;hb=2134520212940b32a0d0e430df02e71591cc4550;hp=42e02b736abc8f3a55ed0b408e664b301eca387d;hpb=3b0e5683fd88917737d9adb681a13bb0b2160ce5;p=SXSI%2FXMLTree.git diff --git a/XMLTree.h b/XMLTree.h index 42e02b7..1268cb6 100644 --- a/XMLTree.h +++ b/XMLTree.h @@ -21,7 +21,7 @@ #ifndef XMLTREE_H_ #define XMLTREE_H_ -#include "TextCollection/TextCollection.h" +#include "TextCollection/TextCollectionBuilder.h" #include #include #include @@ -37,6 +37,7 @@ #include #include using SXSI::TextCollection; +using SXSI::TextCollectionBuilder; // this constant is used to efficiently compute the child operation in the tree @@ -88,7 +89,9 @@ class XMLTree { uint tags_blen, tags_len; /** The texts in the XML document */ + TextCollectionBuilder *TextBuilder; TextCollection *Text; + /** The texts in the XML document (cached for faster display) */ vector CachedText; @@ -125,7 +128,7 @@ public: void print_stats(); /** Data structure constructor */ - XMLTree() {finished = false; initialized = false;}; + XMLTree() {finished = false; initialized = false; Text = 0; TextBuilder = 0; }; /** Data structure destructor */ ~XMLTree(); @@ -150,6 +153,9 @@ public: /** IsChild(x,y): returns whether node x is parent of node y. */ bool IsChild(treeNode x, treeNode y); + + /** IsChild(x,y): returns whether node x is the first child of its parent */ + bool IsFirstChild(treeNode x); /** NumChildren(x): number of children of node x. Constant time with the * data structure of Sadakane. */ @@ -188,8 +194,13 @@ public: * Very fast in BP. */ treeNode FirstChild(treeNode x); + /** LastChild(x): returns the last child of node x. + * Implemented by Kim naively. */ + treeNode LastChild(treeNode x); + /** NextSibling(x): returns the next sibling of node x, assuming it * exists. */ + treeNode NextSibling(treeNode x); /** PrevSibling(x): returns the previous sibling of node x, assuming it @@ -232,7 +243,8 @@ public: * preorder than x and not in the subtree of x. Returns NULLT if there * is none. */ treeNode TaggedFoll(treeNode x, TagType tag); - + + treeNode TaggedFollBelow(treeNode x, TagType tag,treeNode root); /** TaggedFollowingSibling(x,tag) */ treeNode TaggedFollowingSibling(treeNode x, TagType tag); @@ -330,7 +342,7 @@ public: TagType RegisterTag(unsigned char *tagname); bool EmptyText(DocID i) { - return Text->EmptyText(i); + return Text->EmptyText(i); } /** Prefix(s): search for texts prefixed by string s. */ TextCollection::document_result Prefix(uchar const *s) { @@ -385,6 +397,11 @@ public: bool IsLessThan(uchar const *s) { return Text->IsLessThan(s); } + + /** Count(s): Global counting */ + unsigned Count(uchar const *s) { + return Text->Count(s); + } /** CountPrefix(s): counting version of Prefix(s). */ unsigned CountPrefix(uchar const *s) { @@ -414,7 +431,7 @@ public: /** GetText(d): returns the text corresponding to document with * id d. */ uchar* GetText(DocID d) { - return Text->GetText(d); + return Text->GetText(d); } uchar* GetCachedText(DocID d) {