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
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
clear()
clear the stackboolean
contains(N n)
Linear search the stack for contains - not an efficient operationboolean
isEmpty()
N
peek()
show the current stack topN
pop()
pop and return the element from the top of the stackboolean
push(N n)
Add the element to the stack top, optionally failing if there is no capacity (overflow)int
remainingCapacity()
int
size()
-
-
-
Method Detail
-
contains
boolean contains(N n)
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
boolean push(N n)
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
-
-