36 if (
_head ==
nullptr) {
41 while (
curr->next() !=
nullptr) {
49 if (
curr !=
nullptr) {
61 if (
prev !=
nullptr) {
75 if (
lower ==
nullptr ||
lower->next() ==
nullptr) {
106 if (
upper !=
nullptr) {
109 else if (
lower !=
nullptr) {
122 while (
fast->next() !=
nullptr &&
fast->next()->next() !=
nullptr) {
135 return {
this, _head};
139 return {
this,
nullptr};
Represents a location within the Levenshtein automaton.
void next(Position *next)
Assigns the subsequent Position along the current path.
Iterates over the Position nodes in the linked-list of a Levenshtein State.
static auto find_middle(Position *lower) -> Position *
Finds the middle node between lower and the tail.
Position * _head
First Position in the linked-list.
void sort(const Comparator &compare)
Merge-sorts the linked-list of Positions.
void insert_after(Position *curr, Position *next)
Inserts a new Position into the linked-list following an existing member.
void add(Position *next)
Adds a new Position to the tail of the linked-list.
auto begin() -> StateIterator
Returns an iterator over the Positions in this State, beginning at the head and traversing to the tai...
auto end() -> StateIterator
Returns an iterator representing the end of the linked-list of Positions.
auto head() const -> Position *
Returns the first Position in the linked-list of Position nodes.
static auto merge(const Comparator &compare, Position *lower, Position *upper) -> Position *
Merge-sorts the nodes in the range between lower and upper.
void remove(Position *prev, Position *curr)
Removes a Position from the linked-list.
auto merge_sort(const Comparator &compare, Position *lower) -> Position *
Sorts the linked-list of Positions within the Levenshtein automaton.
~State()
Frees any owned allocations.
State()=default
Constructs an empty state, which is most commonly used to represent the intersection of the root node...
void query(ll::Dawg *dawg, const std::string &query_term, std::size_t max_distance)
Various utilities regarding Levenshtein transducers.
std::function< int(Position *, Position *)> Comparator
auto compare(Position *lhs, Position *rhs) -> int
Compares two Positions within the Levenshtein transducer.
void merge(State *state, const std::vector< Position * > &positions)
Merges a list of Positions into the Levenshtein state.