Home / utk / cs140 / sp19 / live_codings_in_lab / part1_concepts / stack_non_templated / stack.hpp
Directory Listing
main.cpp
stack.cpp
stack.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*
 * A simple stack implementation (without templates)
 *
 * Description:
 *     A simple stack implementation that accepts integers as its datatype.
 *     Users are able to push to the back, pop from the back, and access the
 *     top element in the same way as they would with STL's stack.
 *
 * Author:
 *     Clara Nguyen
 */

#ifndef __STACK__
#define __STACK__

class cn_stack {
	public:
		struct node {
			int   data;
			node *next,
			     *prev;

			node();
		};

	public:
		cn_stack();
		~cn_stack();

		void clear();

		void push(const int&);
		void pop();

		int size();

		int top();

		void debug_print();

	private:
		node *sentinel;
		int N;
};

#endif