/
StackInt.java
38 lines (31 loc) · 1014 Bytes
/
StackInt.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
/** A Stack is a data structure in which objects are inserted into
* and removed from the same end (i.e., Last-In, First-Out).
*/
public interface StackInt < E >
{
/** Pushes an item onto the top of the stack and returns
the item pushed.
@param obj The object to be inserted
@return The object inserted
*/
E push(E obj);
/** Returns the object at the top of the stack
without removing it.
post: The stack remains unchanged.
@return The object at the top of the stack
@throws EmptyStackException if stack is empty
*/
E peek();
/** Returns the object at the top of the stack
and removes it.
post: The stack is one item smaller.
@return The object at the top of the stack
@throws EmptyStackException if stack is empty
*/
E pop();
/** Returns true if the stack is empty; otherwise,
returns false.
@return true if the stack is empty
*/
boolean empty();
}//StackInt