summaryrefslogtreecommitdiff
path: root/quackleio/dawgfactory.h
diff options
context:
space:
mode:
authorJohn Fultz <jfultz@wolfram.com>2015-08-24 00:51:48 -0500
committerJohn Fultz <jfultz@wolfram.com>2015-08-24 00:51:48 -0500
commitd1f5f768764d439f02520d9c6c017fcd3ae96b83 (patch)
treee54e047c16bbb0da22b3978cdbbe9b3f86f7add0 /quackleio/dawgfactory.h
parent5e5d414c57d5c7dd8a3037dda1555db5fb7eb486 (diff)
Add a new DAWG format.
Make reader and writer for the new format, while maintaing compatibility with the old. Things to note of the new format... * Now has a header, with version number, MD5, and word count. * No longer has terminator bit. Nodes are terminated by a non-zero playability. * Which means letters have one more bit. So we can now support more than 32 letters. Important for Slovak alphabet. Also, various cleanups and refactorings.
Diffstat (limited to 'quackleio/dawgfactory.h')
-rw-r--r--quackleio/dawgfactory.h26
1 files changed, 17 insertions, 9 deletions
diff --git a/quackleio/dawgfactory.h b/quackleio/dawgfactory.h
index b2cfb76..13837c4 100644
--- a/quackleio/dawgfactory.h
+++ b/quackleio/dawgfactory.h
@@ -29,29 +29,30 @@ public:
DawgFactory(const QString& alphabetFile);
~DawgFactory();
- int wordCount() const { return root.wordCount(); };
- int nodeCount() const { return nodelist.size(); };
+ int wordCount() const { return m_root.wordCount(); };
+ int nodeCount() const { return m_nodelist.size(); };
int encodableWords() const { return m_encodableWords; };
int unencodableWords() const { return m_unencodableWords; };
+ int duplicateWords() const { return m_duplicateWords; };
bool pushWord(const QString& word, bool inSmaller, int playability);
+ void hashWord(const Quackle::LetterString &word);
void generate();
void writeIndex(const QString& fname);
private:
class Node {
public:
- void pushWord(const Quackle::LetterString& word, bool inSmaller, int pb);
- void print(vector< Node* >& nodelist);
+ bool pushWord(const Quackle::LetterString& word, bool inSmaller, int pb);
+ void print(vector< Node* >& m_nodelist);
int letterSum() const;
int wordCount() const;
bool equals(const Node &n) const;
Quackle::Letter c;
- bool t;
bool insmallerdict;
- int playability;
+ int playability; // if nonzero, then terminates word
vector<Node> children;
int pointer;
@@ -69,9 +70,16 @@ private:
int m_encodableWords;
int m_unencodableWords;
- vector< Node* > nodelist;
- Quackle::AlphabetParameters *alphas;
- Node root;
+ int m_duplicateWords;
+ vector< Node* > m_nodelist;
+ Quackle::AlphabetParameters *m_alphas;
+ Node m_root;
+ union {
+ char charptr[16];
+ int32_t int32ptr[4];
+ } m_hash;
+
+ static const char m_versionNumber = 1;
};
#endif