diff options
| author | Joshua Rahm <joshua.rahm@colorado.edu> | 2015-01-27 18:40:32 -0700 |
|---|---|---|
| committer | Joshua Rahm <joshua.rahm@colorado.edu> | 2015-01-27 18:40:32 -0700 |
| commit | 5f3fb9afece2125cbeba79d61a8d88460b7878d7 (patch) | |
| tree | b0e1e60bae9927a9449561bf7fe9431a54d12be9 /project/JavaCommon/src/com/modulus/common/collections/Stack.java | |
| download | LegacyQBar-5f3fb9afece2125cbeba79d61a8d88460b7878d7.tar.gz LegacyQBar-5f3fb9afece2125cbeba79d61a8d88460b7878d7.tar.bz2 LegacyQBar-5f3fb9afece2125cbeba79d61a8d88460b7878d7.zip | |
initial commit
Diffstat (limited to 'project/JavaCommon/src/com/modulus/common/collections/Stack.java')
| -rw-r--r-- | project/JavaCommon/src/com/modulus/common/collections/Stack.java | 57 |
1 files changed, 57 insertions, 0 deletions
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 <T> the type this stack stores + */ +public interface Stack<T> { + /** + * 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 <code>obj</code> 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 <b>not</b> 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(); +} |