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

Class Iterator

libs/base/dfa_helpers.hpp:14–74  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12{
13public:
14 class Iterator
15 {
16 public:
17 Iterator & Move(UniChar c)
18 {
19 if (Rejects())
20 return *this;
21
22 if (Accepts())
23 {
24 auto currentIt = m_it;
25 currentIt.Move(c);
26
27 // While moving m_it, errors number decreases while matching unmatched symbols:
28 // source: a b c d e f
29 // query: a b c d e f
30 // errors: 5 4 3 2 1 0
31 //
32 // After a misprinted symbol errors number remains the same:
33 // source: a b c d e f
34 // query: a b z d e f
35 // errors: 5 4 3 3 2 1
36 //
37 // source: a b c d e f
38 // query: a b d c e f
39 // errors: 5 4 3 3 2 1
40 //
41 // source: a b c d e f
42 // query: a b d e f
43 // errors: 5 4 3 3 2
44 //
45 // source: a b c d e f
46 // query: a b c z d e f
47 // errors: 5 4 3 3 3 2 1
48 //
49 // Errors number cannot decrease after it has increased once.
50
51 if (currentIt.ErrorsMade() > ErrorsMade())
52 return *this;
53 }
54
55 m_it.Move(c);
56 if (m_it.Accepts())
57 m_accepts = true;
58
59 return *this;
60 }
61
62 bool Accepts() const { return m_accepts; }
63 bool Rejects() const { return !Accepts() && m_it.Rejects(); }
64 size_t ErrorsMade() const { return m_it.ErrorsMade(); }
65 size_t PrefixErrorsMade() const { return m_it.PrefixErrorsMade(); }
66
67 private:
68 friend class PrefixDFAModifier;
69
70 Iterator(typename DFA::Iterator it) : m_it(it), m_accepts(m_it.Accepts()) {}
71

Callers 1

BeginMethod · 0.70

Calls 6

RejectsFunction · 0.85
AcceptsFunction · 0.85
ErrorsMadeClass · 0.85
MoveMethod · 0.45
ErrorsMadeMethod · 0.45
AcceptsMethod · 0.45

Tested by

no test coverage detected