From 5f3fb9afece2125cbeba79d61a8d88460b7878d7 Mon Sep 17 00:00:00 2001 From: Joshua Rahm Date: Tue, 27 Jan 2015 18:40:32 -0700 Subject: initial commit --- .../src/com/modulus/common/collections/Stack.java | 57 ++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 project/JavaCommon/src/com/modulus/common/collections/Stack.java (limited to 'project/JavaCommon/src/com/modulus/common/collections/Stack.java') diff --git a/project/JavaCommon/src/com/modulus/common/collections/Stack.java b/project/JavaCommon/src/com/modulus/common/collections/Stack.java new file mode 100644 index 0000000..1d2c36c --- /dev/null +++ b/project/JavaCommon/src/com/modulus/common/collections/Stack.java @@ -0,0 +1,57 @@ +package com.modulus.common.collections; + +/** + * Class defines a better used stack than what is + * in the java api. This stack is an interface + * with many different implementations. + * + * @author jrahm + * + * @param the type this stack stores + */ +public interface Stack { + /** + * Removes and returns the element that is on + * the top of the stack. + * + * @return the element which is on the top of the stack. + */ + public T pop(); + + /** + * Places object obj on the top of + * the stack + * + * @param obj the object to push on the stack. + */ + public void push(T obj); + + /** + * Returns the object on the top of the stack + * but does not remove it. + * + * @return the object on the top of the stack + */ + public T peek(); + + /** + * Returns the number of elements in this + * stack. + * + * @return the number of elements in this stack. + */ + public int size(); + + /** + * Returns true of this stack has no elements, + * returns false otherwise. + * + * @return true it this stack has no elements, false otherwise + */ + public boolean isEmpty(); + + /** + * Empties the stack. + */ + public void clear(); +} -- cgit