liblevenshtein 4.0.0
A library for generating Finite State Transducers based on Levenshtein Automata.
|
Iterates over all the terms in a DAWG dictionary. More...
#include <dawg_iterator.h>
Public Member Functions | |
DawgIterator (DawgNode *root) | |
Constructs an iterator over the terms in a dictionary. | |
DawgIterator (std::size_t term_index) | |
Constructs an iterator representing the boundary following the final term in a dictionary. | |
~DawgIterator () | |
Cleans up all the prefixes allocated by this iterator. | |
auto | operator++ () -> DawgIterator & |
Advances the iterator by one term. | |
auto | operator* () const -> std::string |
Returns the current dictionary term. | |
auto | operator== (const DawgIterator &other) const -> bool |
Compares this iterator with one representing the boundary following the final term in the dictionary. | |
Private Member Functions | |
void | advance () |
Advances this iterator by one term. | |
Private Attributes | |
std::vector< Prefix * > | _prefixes |
Used to construct dictionary terms by collecting consecutive edge labels from the root node to their respective final nodes. | |
std::queue< Prefix * > | _pending |
Intermediate prefixes that have not reached all their final nodes yet. | |
std::string | _next_value |
Value of this iterator, i.e. | |
std::size_t | _term_index = 0 |
Current index of the enumerated terms in the dictinary. | |
Iterates over all the terms in a DAWG dictionary.
Definition at line 15 of file dawg_iterator.h.
liblevenshtein::DawgIterator::DawgIterator | ( | DawgNode * | root | ) |
Constructs an iterator over the terms in a dictionary.
Terms are yielded as they are reached by traversing the consecutive outgoing edges from the root node.
root | Root node of the dictionary. |
Definition at line 6 of file dawg_iterator.cpp.
References _pending, _prefixes, advance(), and query().
liblevenshtein::DawgIterator::DawgIterator | ( | std::size_t | term_index | ) |
Constructs an iterator representing the boundary following the final term in a dictionary.
term_index | Size of the dictionary. Each term is enumerated from 0, so when the term_index reaches the size of the dictionary, all terms have been traversed. |
Definition at line 13 of file dawg_iterator.cpp.
liblevenshtein::DawgIterator::~DawgIterator | ( | ) |
|
private |
Advances this iterator by one term.
Definition at line 37 of file dawg_iterator.cpp.
References _next_value, _pending, _prefixes, liblevenshtein::DawgNode::for_each_edge(), liblevenshtein::DawgNode::is_final(), and query().
Referenced by DawgIterator().
auto liblevenshtein::DawgIterator::operator* | ( | ) | const -> std::string |
Returns the current dictionary term.
Definition at line 29 of file dawg_iterator.cpp.
References _next_value.
auto liblevenshtein::DawgIterator::operator++ | ( | ) | -> DawgIterator & |
Advances the iterator by one term.
Definition at line 23 of file dawg_iterator.cpp.
auto liblevenshtein::DawgIterator::operator== | ( | const DawgIterator & | other | ) | const -> bool |
Compares this iterator with one representing the boundary following the final term in the dictionary.
When this returns false, all terms in the dictionary have been iterated over. By convention, this is only used to compare iterators over the same dictionary.
other | An iterator whose location in the dictionary must be compared with the boundary following its final term. |
Definition at line 33 of file dawg_iterator.cpp.
References query().
|
private |
Value of this iterator, i.e.
the current dictionary term.
Definition at line 78 of file dawg_iterator.h.
Referenced by advance(), and operator*().
|
private |
Intermediate prefixes that have not reached all their final nodes yet.
Definition at line 75 of file dawg_iterator.h.
Referenced by advance(), and DawgIterator().
|
private |
Used to construct dictionary terms by collecting consecutive edge labels from the root node to their respective final nodes.
Definition at line 72 of file dawg_iterator.h.
Referenced by advance(), DawgIterator(), and ~DawgIterator().
|
private |
Current index of the enumerated terms in the dictinary.
Definition at line 81 of file dawg_iterator.h.