-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStack.java
45 lines (35 loc) · 1.03 KB
/
Stack.java
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
/**
* Stack Abstract Data Type. A Stack is a linear data structure
* following last-in-first-out protocol, i.e. the last element
* that has been added onto the Stack, is the first one to
* be removed.
*
* @author Marcel Turcotte
*/
public interface Stack<E> {
/**
* Tests if this Stack is empty.
*
* @return true if this Stack is empty; and false otherwise.
*/
public abstract boolean isEmpty();
/**
* Returns a reference to the top element; does not change
* the state of this Stack.
*
* @return The top element of this stack without removing it.
*/
public abstract E peek();
/**
* Removes and returns the element at the top of this stack.
*
* @return The top element of this stack.
*/
public abstract E pop();
/**
* Puts an element onto the top of this stack.
*
* @param element the element be put onto the top of this stack.
*/
public abstract void push( E element );
}