-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStackADT.java
50 lines (40 loc) · 1.1 KB
/
StackADT.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
46
47
48
49
50
import java.util.NoSuchElementException;
/**
* An interface that describes a stack abstract data type
*
* @author Benjamin Kuperman (Spring 2005, Spring 2012, Spring 2014)
*/
public interface StackADT<T> {
/**
* Add an item onto the stack
* @param item the data item to add (of type T)
*/
void push(T item);
/**
* Remove the top item from the stack
* @return the top item in the stack
* @throws NoSuchElementException if the stack is empty
*/
T pop() throws NoSuchElementException;
/**
* Display the top item from the stack without removing it
* @return the top item in the stack
* @throws NoSuchElementException if the stack is empty
*/
T top() throws NoSuchElementException;
/**
* Find how many items are in the stack
* @return the number of items in the stack
*/
int size();
StackADT clone();
/**
* Determine if the stack is empty
* @return true if the size is 0, false otherwise
*/
boolean isEmpty();
/**
* Clear out the data structure
*/
void clear();
}