fix minitoc/heading error
[vspell.git] / libvspell / cgen.cpp
blobeae95334ffa3fa40bf8c03b27a6452a2ec3134f7
1 #include "cgen.h" // -*- tab-width: 2 -*-
3 using namespace std;
5 void CGen::init(const vector<uint> &_limit)
7 limit = _limit;
8 nr_limit = limit.size();
9 iter.resize(nr_limit);
10 for (uint i = 0;i < nr_limit;i ++)
11 iter[i] = 0;
12 cur = 0;
15 void CGen::done()
19 /**
20 Generate every possible 3-misspelled-positions.
21 Then call WFST::generate_misspelled_words.
24 bool CGen::step(vector<uint> &_pos)
26 while (cur >= 0) {
28 if (cur == nr_limit-1) {
29 _pos = iter;
30 while (cur >= 0 && iter[cur] == limit[cur]-1)
31 cur --;
32 if (cur >= 0)
33 iter[cur]++;
34 return true;
37 cur ++;
38 if (cur < nr_limit)
39 iter[cur] = 0;
41 return false;