Interface Stack<N>
- All Known Subinterfaces:
BlockingStack<N>
- All Known Implementing Classes:
ConcurrentStack
,FixedStack
public interface Stack<N>
Created by jcairns on 6/11/14.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
clear the stackboolean
Linear search the stack for contains - not an efficient operationboolean
isEmpty()
peek()
show the current stack toppop()
pop and return the element from the top of the stackboolean
Add the element to the stack top, optionally failing if there is no capacity (overflow)int
int
size()
-
Method Details
-
contains
Linear search the stack for contains - not an efficient operation- Parameters:
n
- - Object to test for containment- Returns:
- boolean - true if n is contained somewhere in the stack
-
push
Add the element to the stack top, optionally failing if there is no capacity (overflow)- Parameters:
n
- - element to push- Returns:
- boolean - true if push succeeded
-
peek
N peek()show the current stack top- Returns:
- N - the element at the top of the stack or null
-
pop
N pop()pop and return the element from the top of the stack- Returns:
- N - the element, or null if the stack is empty
-
size
int size()- Returns:
- int - the size of the stack in number of elements
-
remainingCapacity
int remainingCapacity()- Returns:
- int - the number of empty slots available in the stack
-
isEmpty
boolean isEmpty()- Returns:
- boolean - true if stack is empty
-
clear
void clear()clear the stack
-