fix minitoc/heading error
[vspell.git] / libvspell / shuffle.cpp
blob7a02c2bb8e168645bf95b831d22b5525c8896a3a
1 // -*- tab-width: 2 mode: c++ -*-
2 #include "shuffle.h"
3 #include "spell.h"
5 using namespace std;
7 void CharInserter::init(const char *input_)
9 input = input_;
10 len = input.size();
11 i = i2 = 0;
14 bool CharInserter::step(string &output)
16 static char *candidates = "qwertyuiopasdfghjklzxcvbnm";
17 uint len2 = strlen(candidates);
19 if (i > len)
20 return false;
22 output = input;
23 output.insert(output.begin()+i,candidates[i2]);
24 i2 ++;
25 if (i2 == len2) {
26 i2 = 0;
27 i ++;
29 return true;
32 void CharInserter::done()
36 void CharEraser::init(const char *input_)
38 input = input_;
39 len = input.size();
40 i = 0;
43 bool CharEraser::step(string &output)
45 if (i >= len)
46 return false;
48 output = input;
49 output.erase(i,1);
50 i ++;
52 return true;
55 void CharEraser::done()
59 void CharTransposer::init(const char *input_)
61 input = input_;
62 len = input.size();
63 i = 0;
66 bool CharTransposer::step(string &output)
68 if (i >= len-1)
69 return false;
71 char c;
72 output = input;
73 c = output[i];
74 output[i] = output[i+1];
75 output[i+1] = c;
76 i ++;
78 return true;
81 void CharTransposer::done()