From a813848effa433c2c75b56b67d12129cc1bbd84a Mon Sep 17 00:00:00 2001 From: Aditya Date: Mon, 12 Sep 2022 19:03:24 +0530 Subject: [PATCH] add stack ADT --- stack/Stack.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 stack/Stack.java diff --git a/stack/Stack.java b/stack/Stack.java new file mode 100644 index 0000000..01f757c --- /dev/null +++ b/stack/Stack.java @@ -0,0 +1,19 @@ +/** Stack ADT */ +public interface Stack { + /** 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(); +};