| Classes | Functions | DevRef | Qt API | Qtopia Documentation | ![]() |
The QDawg class provides an implementation of a Directed Acyclic Word Graph. More...
#include <qdawg.h>
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.
Replaces all the DAWG's words with words read from dev.
See also write().
See also write().
This file is part of the Qtopia , copyright © 1995-2002 Trolltech, all rights reserved.
Copyright © 2001-2002 Trolltech | Trademarks | Qtopia version 1.5.0
|