#include </home/clem/local/src/opie/library/qdawg.h>
Collaboration diagram for QDawg:

Public Member Functions | |
| QDawg () | |
| ~QDawg () | |
| bool | readFile (const QString &) |
| bool | read (QIODevice *dev) |
| bool | write (QIODevice *dev) const |
| bool | createFromWords (QIODevice *dev) |
| void | createFromWords (const QStringList &) |
| QStringList | allWords () const |
| bool | contains (const QString &) const |
| int | countWords () const |
| const Node * | root () const |
| void | dump () const |
Static Public Attributes | |
| static const int | nodebits = 18 |
Private Attributes | |
| QDawgPrivate * | d |
Friends | |
| class | QDawgPrivate |
Classes | |
| class | Node |
| The QDawg::Node class represents one node of a QDawg. More... | |
A DAWG provides very fast look-up of words in a word list.
The word list is created using readFile(), read() or createFromWords(). A list of all the DAWG's words is returned by allWords(), and the total number of words is returned by countWords(). Use contains() to see if a particular word is in the DAWG. The root node is returned by root().
A global DAWG is maintained for the current locale. See the Global class for details.
The structure of a DAWG is a graph of Nodes. There are no cycles in the graph (since there are no inifinitely repeating words). Each Node is a member of a list of Nodes called a child list. Each Node in the child list has a letter, an isWord flag, at most one jump arc, and at most one arc to the next child in the list.
If you traverse the Nodes in a DAWG, starting from the root(), and you concatenate all the letters from the single child in each child list that you visit, at every Node which has the isWord flag set your concatenation will be a word in the list represented by the DAWG.
For example, the DAWG below represents the word list: ban, band, can, cane, cans, pan, pane, pans.
This structuring not only provides O(1) lookup of words in the word list, but also produces a smaller storage file than a plain text file word list.
qdawg.png
Definition at line 28 of file qdawg.h.
|
|
Constructs a new empty DAWG. Definition at line 443 of file qdawg.cpp. References d. |
|
|
Deletes the DAWG. Definition at line 451 of file qdawg.cpp. References d. |
|
|
Returns a list of all the words in the DAWG. Definition at line 499 of file qdawg.cpp. References QDawgPrivate::appendAllWords(), and d. Referenced by Global::addWords(). |
|
|
Returns TRUE if the DAWG contains the word s; otherwise returns FALSE. Definition at line 578 of file qdawg.cpp. References QDawgPrivate::contains(), d, and FALSE. |
|
|
Returns the number of words in the DAWG. Definition at line 561 of file qdawg.cpp. References QDawgPrivate::countWords(), and d. |
|
|
Replaces all the DAWG's words with the words in the list. Definition at line 481 of file qdawg.cpp. References QValueList< T >::begin(), QValueList< T >::count(), d, QValueList< T >::end(), QTrie::insertWord(), and QDawgPrivate. |
|
|
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Replaces all the DAWG's words with words read from dev. Definition at line 460 of file qdawg.cpp. References QTextStream::atEnd(), d, QString::fromUtf8(), i, QTrie::insertWord(), QDawgPrivate, QTextStream::readLine(), and TRUE. Referenced by Global::addWords(), and Global::fixedDawg(). |
|
|
For internal use only. For debugging: prints out the DAWG contents. Definition at line 588 of file qdawg.cpp. References d, and QDawgPrivate::dump(). |
|
|
Replaces the DAWG with the DAWG in dev. The file is memory-mapped.
Definition at line 539 of file qdawg.cpp. References d, FALSE, QDawgPrivate::ok(), QDawgPrivate, and TRUE. |
|
|
Replaces the DAWG with the DAWG in filename. The file is memory-mapped.
Definition at line 513 of file qdawg.cpp. References d, QFile::encodeName(), f, FALSE, and QDawgPrivate. Referenced by Global::dawg(), and Global::fixedDawg(). |
|
|
Returns the root Node of the DAWG. Definition at line 569 of file qdawg.cpp. References d, and QDawgPrivate::root(). |
|
|
Writes the DAWG to dev, in a custom QDAWG format. Definition at line 553 of file qdawg.cpp. References d, TRUE, and QDawgPrivate::write(). Referenced by Global::addWords(), and Global::fixedDawg(). |
|
|
Definition at line 66 of file qdawg.h. Referenced by createFromWords(), read(), and readFile(). |
|
|
Definition at line 67 of file qdawg.h. Referenced by allWords(), contains(), countWords(), createFromWords(), dump(), QDawg(), read(), readFile(), root(), write(), and ~QDawg(). |
|
|
|
1.4.2