forked from Speiger/Primitive-Collections
62 lines
1.4 KiB
Plaintext
62 lines
1.4 KiB
Plaintext
package speiger.src.collections.PACKAGE.collections;
|
|
|
|
import speiger.src.collections.utils.Stack;
|
|
|
|
/**
|
|
* A Type-Specific {@link Stack} that reduces (un)boxing
|
|
*/
|
|
public interface STACK
|
|
{
|
|
/**
|
|
* Inserts a given Object on top of the stack
|
|
* @param e the Object to insert
|
|
* @see Stack#push(Object)
|
|
*/
|
|
public void push(KEY_TYPE e);
|
|
|
|
/**
|
|
* Removes the Object on top of the stack.
|
|
* @return the element that is on top of the stack
|
|
* @throws ArrayIndexOutOfBoundsException if the stack is empty
|
|
* @see Stack#pop()
|
|
*/
|
|
public KEY_TYPE pop();
|
|
|
|
/**
|
|
* Provides the Object on top of the stack
|
|
* @return the element that is on top of the stack
|
|
* @throws ArrayIndexOutOfBoundsException if the stack is empty
|
|
* @see Stack#top()
|
|
*/
|
|
public default KEY_TYPE top() {
|
|
return peek(0);
|
|
}
|
|
|
|
/**
|
|
* Provides the Selected Object from the stack.
|
|
* Top to bottom
|
|
* @param index of the element that should be provided
|
|
* @return the element that was requested
|
|
* @throws ArrayIndexOutOfBoundsException if the index is out of bounds
|
|
* @see Stack#peek(int)
|
|
*/
|
|
public KEY_TYPE peek(int index);
|
|
|
|
/**
|
|
* Clears the stack
|
|
*/
|
|
public void clear();
|
|
|
|
/**
|
|
* Provides the amount of elements currently in the stack
|
|
* @return amount of elements in the list
|
|
*/
|
|
public int size();
|
|
|
|
/**
|
|
* @return if the stack is empty
|
|
*/
|
|
public default boolean isEmpty() {
|
|
return size() == 0;
|
|
}
|
|
} |