////////////////////////////////////////////////////////////////////////////
// Class CSA::THuffAlphabetRank
-
+// FIXME Unused code
CSA::THuffAlphabetRank::THuffAlphabetRank(uchar *s, TextPosition n, TCodeEntry *codetable, unsigned level) {
left = NULL;
right = NULL;
delete bitrank;
}
-/**
- * Saving data fields:
- BitRank *bitrank;
- bool leaf;
- uchar ch;
- left child;
- right child;
-*/
-void CSA::THuffAlphabetRank::Save(FILE *file)
-{
-
-}
-
-CSA::THuffAlphabetRank::THuffAlphabetRank(FILE *file)
-{
-
-
-}
-/////////////////////////////////////////////f///////////////////////////////
+////////////////////////////////////////////////////////////////////////////
// Class CSA
/**
/******************************************************************
* Counting queries
*/
+ulong CSA::Count(uchar const * pattern) const
+{
+ TextPosition m = strlen((char *)pattern);
+ if (m == 0)
+ return 0;
+
+ TextPosition sp = 0, ep = 0;
+ unsigned count = (unsigned) Search(pattern, m, &sp, &ep);
+ return count;
+}
+
unsigned CSA::CountPrefix(uchar const * pattern) const
{
TextPosition m = strlen((char *)pattern);
#else
# define W 32
#endif
+#undef bitset
/**
void MakeStatic();
bool EmptyText(DocId) const;
uchar* GetText(DocId) const;
+ /**
+ * Next method is not supported:
+ * Supporting GetText for some substring [i,j]
+ * would require more space.
+ */
// uchar* GetText(DocId, TextPosition, TextPosition) const;
bool IsPrefix(uchar const *) const;
bool IsContains(uchar const *) const;
bool IsLessThan(uchar const *) const;
+ ulong Count(uchar const *) const;
unsigned CountPrefix(uchar const *) const;
unsigned CountSuffix(uchar const *) const;
unsigned CountEqual(uchar const *) const;
}
private:
+ // FIXME Unused code
class TCodeEntry {
public:
unsigned count;
};
+ // FIXME Unused code
class THuffAlphabetRank {
// using fixed 0...255 alphabet
private:
}
};
+ // FIXME Unused code
class node {
private:
unsigned weight;
static TCodeEntry *makecodetable(uchar *, TextPosition);
};
+ // FIXME Unused code
static const unsigned char print = 1;
static const unsigned char report = 1;
static const uchar versionFlag;
*
* Note: Do we need this?
* Forward iterator would be really in-efficient compared to
- * getText(k) and getText(k, i, j).
+ * getText(k).
*
* TODO Define and implement const_reverse_iterator.
*/
virtual bool IsLessThan(uchar const *) const = 0;
/**
- * Counting queries
- *
+ * Counting queries
+ * Result is the number of occurrences.
+ */
+ virtual ulong Count(uchar const *) const = 0;
+ /**
+ * More counting queries
* Result is the number of documents.
*/
virtual unsigned CountPrefix(uchar const *) const = 0;
typedef std::vector<std::pair<DocId, TextPosition> > full_result;
virtual full_result FullContains(uchar const *) const = 0;
-
- /**
- *Debug
- *
- */
- virtual TextPosition Lookup(TextPosition) const = 0;
protected:
// Protected constructor; call the static function InitTextCollection().
TextCollection() { };