view algs4-c++/src/Buffer.hpp @ 27:80ca1973e3bd

Fleshed out Queue::generic_iterator a bit more to make it a more or less complete example of implmenting an iterator.
author Eris Caffee <discordia@eldalin.com>
date Tue, 23 Jun 2015 17:14:09 -0500
parents
children
line source
1 // Sedgewick and Wayne, Algorithms, 4th ed. problem 1.3.44
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.
8 #ifndef BUFFER_HPP
9 #define BUFFER_HPP
11 #include <cstddef>
13 #include "Stack.hpp"
15 class Buffer {
16 public:
17 Buffer( void );
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 );
26 private:
27 size_t cursor;
29 bool use_s1;
30 Stack<char> s1;
31 Stack<char> s2;
32 };
34 #endif