Add EmptyText(id) method which checks if the text
authorkim <kim@3cdefd35-fc62-479d-8e8d-bae585ffb9ca>
Fri, 12 Dec 2008 09:24:50 +0000 (09:24 +0000)
committerkim <kim@3cdefd35-fc62-479d-8e8d-bae585ffb9ca>
Fri, 12 Dec 2008 09:24:50 +0000 (09:24 +0000)
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

CSA.cpp
CSA.h
TextCollection.h

diff --git a/CSA.cpp b/CSA.cpp
index 754dfa8..db96b4b 100644 (file)
--- 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 (file)
--- 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;
 
index e7f0d4b..6a4eb1c 100644 (file)
@@ -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
          *