MCPcopy Create free account
hub / github.com/comaps/comaps / Normalize

Method Normalize

libs/base/levenshtein_dfa.cpp:164–189  ·  view source on GitHub ↗

LevenshteinDFA::State ---------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

162
163// LevenshteinDFA::State ---------------------------------------------------------------------------
164void LevenshteinDFA::State::Normalize()
165{
166 size_t i = 0;
167 size_t j = m_positions.size();
168
169 while (i < j)
170 {
171 auto const & cur = m_positions[i];
172
173 auto it = find_if(m_positions.begin(), m_positions.begin() + j,
174 [&](Position const & rhs) { return cur.SubsumedBy(rhs); });
175 if (it != m_positions.begin() + j)
176 {
177 ASSERT_GREATER(j, 0, ());
178 --j;
179 std::swap(m_positions[i], m_positions[j]);
180 }
181 else
182 {
183 ++i;
184 }
185 }
186
187 m_positions.erase(m_positions.begin() + j, m_positions.end());
188 base::SortUnique(m_positions);
189}
190
191// LevenshteinDFA ----------------------------------------------------------------------------------
192// static

Callers 1

MoveMethod · 0.45

Calls 7

SortUniqueFunction · 0.85
SubsumedByMethod · 0.80
swapFunction · 0.70
sizeMethod · 0.45
beginMethod · 0.45
eraseMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected