Mercurial > Algorithms__Sedgewick
comparison algs4-c++/src/Buffer.hpp @ 22:c2cbfdf528f6
1.3.44 Ugh. I would never use this in real life but it seems to be what they want.
author | Eris Caffee <discordia@eldalin.com> |
---|---|
date | Tue, 23 Jun 2015 11:02:31 -0500 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:e1ed0235c7af |
---|---|
1 // Sedgewick and Wayne, Algorithms, 4th ed. problem 1.3.44 | |
2 | |
3 // Two stack implementation. I don't know why anyone would actually want to use | |
4 // an implmentation like this, but it's what they suggested in the problem. I | |
5 // guess it's just an "exercise" after all. | |
6 | |
7 | |
8 #ifndef BUFFER_HPP | |
9 #define BUFFER_HPP | |
10 | |
11 #include <cstddef> | |
12 | |
13 #include "Stack.hpp" | |
14 | |
15 class Buffer { | |
16 public: | |
17 Buffer( void ); | |
18 | |
19 void insert( char c ); | |
20 char get( void ); | |
21 char delete( void ); | |
22 void left( size_t k ); | |
23 void right( size_t k ); | |
24 size_t size( void ); | |
25 | |
26 private: | |
27 size_t cursor; | |
28 | |
29 bool use_s1; | |
30 Stack<char> s1; | |
31 Stack<char> s2; | |
32 }; | |
33 | |
34 #endif |