mirror of
https://git.adityakumar.xyz/data-structures.git
synced 2024-11-21 17:32:53 +00:00
add stack ADT
This commit is contained in:
parent
150bf2ba9b
commit
a813848eff
1 changed files with 19 additions and 0 deletions
19
stack/Stack.java
Normal file
19
stack/Stack.java
Normal file
|
@ -0,0 +1,19 @@
|
|||
/** Stack ADT */
|
||||
public interface Stack<E> {
|
||||
/** Reinitialize the stack. The user is responsible for reclaiming the storage used by the stack elements. */
|
||||
public void clear();
|
||||
|
||||
/** Push an element ontp the top of the stack.
|
||||
@param it The element being pushed onto the stack. */
|
||||
public void push(E it);
|
||||
|
||||
/** Remove and return the element at the top of the stack.
|
||||
@return The element at the top of the stack. */
|
||||
public E pop();
|
||||
|
||||
/** @return A copy of the top element. */
|
||||
public E topValue();
|
||||
|
||||
/** @return The number of elements in the stack. */
|
||||
public int length();
|
||||
};
|
Loading…
Reference in a new issue