summaryrefslogtreecommitdiff
path: root/src/stack.h
blob: 30e2a1943aabd01b971da8f77ed14c7bfc55ddbc (plain)
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
47
48
49
50
#ifndef STACK_H
#define STACK_H
#include "linkedlist.h"

/** An ultra-simple stack implementation that just uses a linked list.
  *@author Mike Buland
  */
class Stack
{
public:
	/** Pushes a new value onto the top of the stack.
	  *@param data A new value for the stack.
	  *@author Mike Buland
	  */
	void push( void *data );

	/** Returns the top value off of the stack, but doesn't remove it from the
	  * stack.
	  *@returns The value at the top of the stack.
	  *@author Mike Buland
	  */
	void *top();

	/** Pops the top item off of the stack.
	  *@author Mike Buland
	  */
	void pop();

	/** Gets the top item off of the stack, pops it off the stack, and returns
	  * it.
	  *@returns The value at the top of the stack.
	  *@author Mike Buland
	  */
	void *poptop();

	/** Checks if the stack is empty.
	  *@returns True if the stack is empty, and false if it has things in it.
	  *@author Mike Buland
	  */
	bool isEmpty();

	/** Empty the stack.
	  *@author Mike Buland
	  */
	void empty();

private:
	LinkedList lStackData;	/**< The actual stack data. */
};
#endif