@@ -215,14 +215,29 @@ template<class T, class E = char> class Trie {
215
215
return this ->stackyTheLittleStack == rhs.stackyTheLittleStack ;
216
216
};
217
217
218
+ // TrieIterator& operator ++() {
219
+ // while(stackyTheLittleStack.top().first++ == stackyTheLittleStack.top().second){
220
+ // stackyTheLittleStack.pop();
221
+ // }
222
+ // viewTrie + '\n' + addSpace(stackyTheLittleStack.size()) + stackyTheLittleStack.top().first++->first;
223
+ // slideLeft(static_cast<InternalNode*>(stackyTheLittleStack.top().first++->second));
224
+ // return *this;
225
+ // };
218
226
TrieIterator& operator ++() {
219
- while (stackyTheLittleStack.top ().first ++ == stackyTheLittleStack.top ().second ){
220
- stackyTheLittleStack.pop ();
221
- }
222
- viewTrie + ' \n ' + addSpace (stackyTheLittleStack.size ()) + stackyTheLittleStack.top ().first ++->first ;
223
- slideLeft (static_cast <InternalNode*>(stackyTheLittleStack.top ().first ++->second ));
224
- return *this ;
225
- };
227
+ popStack ();
228
+ viewTrie += ' \n ' + addSpace (stackyTheLittleStack.size ()) += stackyTheLittleStack.top ().first ->first ;
229
+ slideLeft (static_cast <InternalNode*>(stackyTheLittleStack.top ().first ->second ));
230
+ return *this ;
231
+ };
232
+
233
+ void popStack () {
234
+ typename mappy::iterator topIter = ++(stackyTheLittleStack.top ().first );
235
+ typename mappy::iterator topEnd = (stackyTheLittleStack.top ().second );
236
+ if (topIter == topEnd) {
237
+ stackyTheLittleStack.pop ();
238
+ popStack ();
239
+ }
240
+ }
226
241
227
242
std::string addSpace (int stackSize){
228
243
std::string result = " " ;
@@ -263,7 +278,7 @@ template<class T, class E = char> class Trie {
263
278
* Insert a single InternalNode or Leaf.
264
279
*/
265
280
iterator insert (const value_type& value) {
266
- key_type a = value.first ;
281
+ key_type a = value.first + ' # ' ;
267
282
T b = value.second ;
268
283
root->insert (a,b);
269
284
// return find(a);
@@ -294,8 +309,10 @@ template<class T, class E = char> class Trie {
294
309
295
310
void showTrie () {
296
311
iterator cd = begin ();
297
- while (cd != end ()) {
312
+ iterator ed = cd;
313
+ while (cd != end () && ++ed != end ()) {
298
314
++cd;
315
+ ed=cd;
299
316
}
300
317
std::cout << cd.viewTrie << std::endl;
301
318
cd.viewTrie = " " ;
0 commit comments