From: kim Date: Fri, 12 Dec 2008 09:24:50 +0000 (+0000) Subject: Add EmptyText(id) method which checks if the text X-Git-Url: http://git.nguyen.vg/gitweb/?a=commitdiff_plain;h=56d77631b00f8622c211db6721cb087a5d29f0e2;p=SXSI%2FTextCollection.git Add EmptyText(id) method which checks if the text pointed by id is the empty string. This is way faster than testing whether GetText(id) == "". git-svn-id: svn+ssh://idea.nguyen.vg/svn/sxsi/trunk/TextCollection@24 3cdefd35-fc62-479d-8e8d-bae585ffb9ca --- diff --git a/CSA.cpp b/CSA.cpp index 754dfa8..db96b4b 100644 --- a/CSA.cpp +++ b/CSA.cpp @@ -209,6 +209,11 @@ void CSA::MakeStatic() maketables(); } +bool CSA::EmptyText(DocId k) const +{ + assert(k < (DocId)textLength.size()); + return (1 == textLength[k].first); +} uchar* CSA::GetText(DocId k) const { diff --git a/CSA.h b/CSA.h index 9f6c500..00cf1c6 100644 --- a/CSA.h +++ b/CSA.h @@ -55,6 +55,7 @@ public: */ void InsertText(uchar const *); void MakeStatic(); + bool EmptyText(DocId) const; uchar* GetText(DocId) const; uchar* GetText(DocId, TextPosition, TextPosition) const; diff --git a/TextCollection.h b/TextCollection.h index e7f0d4b..6a4eb1c 100644 --- a/TextCollection.h +++ b/TextCollection.h @@ -86,7 +86,13 @@ namespace SXSI * New texts can not be inserted after this operation. */ virtual void MakeStatic() = 0; - + + /** + tests if the string pointed to by DocId is empty + */ + + virtual bool EmptyText(DocId) const = 0; + /** * Displaying content *