-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStack.java
More file actions
40 lines (34 loc) · 891 Bytes
/
Stack.java
File metadata and controls
40 lines (34 loc) · 891 Bytes
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
interface Stack<T> {
/*
* Purpose: Insert an item onto the top of the stack
* Parameters: T - the item to insert
* Returns: Nothing
*/
public void push(T v);
/*
* Purpose: Removes and returns the top item from the stack
* Parameters: None
* Returns: T - the data value of the element removed
* Throws: EmptyStackException if stack is empty
*/
public T pop();
/*
* Purpose: Accesses the top item on the stack
* Parameters: None
* Returns: T - the data value of the top element
* Throws: EmptyStackException if stack is empty
*/
public T top();
/*
* Purpose: Determines whether the stack is empty
* Parameters: None
* Returns: boolean - true if the stack is empty, false otherwise
*/
public boolean isEmpty();
/*
* Purpose: Removes all elements from the stack
* Parameters: None
* Returns: Nothing
*/
public void popAll();
}