liblevenshtein 4.0.0
A library for generating Finite State Transducers based on Levenshtein Automata.
Loading...
Searching...
No Matches
state_iterator.cpp
Go to the documentation of this file.
3
4namespace liblevenshtein {
5
7 : _outer(outer),
8 _state(state),
9 _curr(head),
10 _next(head != nullptr ? head->next() : nullptr)
11{}
12
14 advance();
15 return *this;
16}
17
19 return _curr;
20}
21
22auto StateIterator::operator==(const StateIterator &other) const -> bool {
23 return (_curr == other._curr) && (_next == other._next);
24}
25
27 if (_curr != nullptr) {
29 } else {
31 }
33}
34
36 if (_curr != nullptr) {
37 if (_outer != nullptr && _outer->_next == _curr) {
39 }
41 _curr = nullptr;
42 }
43}
44
46 if (_curr != nullptr) {
47 _prev = _curr;
48 }
49
50 _curr = _next;
51
52 if (_next != nullptr) {
53 _next = _next->next();
54 }
55}
56
57} // namespace liblevenshtein
Represents a location within the Levenshtein automaton.
Definition position.h:11
void next(Position *next)
Assigns the subsequent Position along the current path.
Definition position.cpp:15
Iterates over the Position nodes in the linked-list of a Levenshtein State.
auto operator==(const StateIterator &other) const -> bool
Returns whether this StateIterator is equivalent to another.
StateIterator * _outer
Outermost iterator over the same linked-list, used for unsubsumption.
auto operator++() -> StateIterator &
Advances the Position in the linked-list by one.
void insert(Position *position)
Inserts a new Position after the current one in the linked-list.
Position * _curr
Current Position being iterated over.
void advance()
Advances the Position being iterated over by one.
auto operator*() const -> Position *
Returns a pointer to the current Position in the linked-list.
Position * _next
Next Position to be iterated over.
State * _state
Levenshtein State that owns the linked-list being iterated over.
StateIterator(State *state, Position *head, StateIterator *outer=nullptr)
Constructs a new StateIterator of the Position nodes of state, with an optional outer pointer for uns...
Position * _prev
Previous Position being iterated over.
void remove()
Removes the current Position from the linked-list.
Consists of a closure of Position nodes within the Levenshtein automaton.
Definition state.h:23
void insert_after(Position *curr, Position *next)
Inserts a new Position into the linked-list following an existing member.
Definition state.cpp:48
void head(Position *head)
Sets the first element in the linked-list of Position nodes.
Definition state.cpp:26
void remove(Position *prev, Position *curr)
Removes a Position from the linked-list.
Definition state.cpp:58
void query(ll::Dawg *dawg, const std::string &query_term, std::size_t max_distance)
Definition main.cpp:25
Various utilities regarding Levenshtein transducers.
Definition namespaces.dox:9