-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStackInterface.h
More file actions
73 lines (66 loc) · 1.61 KB
/
StackInterface.h
File metadata and controls
73 lines (66 loc) · 1.61 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/** @file
*
* @course CS1521
* @section 1
* @term Spring 2023
*
* StackInterface class template definition.
*
* Adapted from page 197 in Carrano 7e.
*
* @author Frank M. Carrano
* @author Timothy Henry
* @author Steve Holtz
*
* @date 10 Feb 2023
*
* @version 7.0 */
#ifndef STACK_INTERFACE_
#define STACK_INTERFACE_
/** @class StackInterface StackInterface.h "StackInterface.h"
*
* Definition of StackInterface class template. */
template <typename ItemType>
class StackInterface {
public:
/** Virtual destructor. */
virtual ~StackInterface() = default;
/** Tests whether this stack is empty.
*
* @pre None.
*
* @post None.
*
* @return True if this stack is empty, or false. */
virtual bool isEmpty() const = 0;
/** Adds a new entry to the top of this stack.
*
* @pre None.
*
* @post If successful, newEntry is stored at the top of this
* stack.
*
* @param newEntry The object to be added as a new entry.
*
* @return True if addition was successful, or false. */
virtual bool push(const ItemType& newEntry) = 0;
/** Removes the top of this stack.
*
* @pre None.
*
* @post If successful, the top of this stack has been removed.
*
* @return True if removal was successful, or false. */
virtual bool pop() = 0;
/** Retrieves the top of this stack.
*
* @pre This stack is not empty.
*
* @post None.
*
* @return The top of this stack.
*
* @throws PrecondViolatedExcep If the precondition is violated. */
virtual ItemType peek() const = 0;
};
#endif