-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStack.java
More file actions
30 lines (19 loc) · 760 Bytes
/
Copy pathStack.java
File metadata and controls
30 lines (19 loc) · 760 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
/*
Home-grown Stack<E> interface.
A stack is a linear data structure where all the operations are done
on only one end (the "top" of the stack). It's a "last-in, first-out"
(LIFO) structure - the last element added is the first element to be
removed.
This interface supports the isEmpty, push, pop, and peek operations.
*/
// note: all methods declared in an interface are public and abstract
public interface Stack<E> {
// Returns whether or not the stack is empty
boolean isEmpty();
// Adds a new element to the top of the stack
void push(E newValue);
// Removes the node from list and returns the data that was in the node
E pop();
// Returns (but does not remove) the element at the top of the stack
E peek();
}