package cse1030.datastructures; import java.util.LinkedList; /** * A simple stack implementation supporting push, pop, and * isEmpty operations. * * @author CSE1030 * * @param the type of element held by this stack */ public class Stack { private LinkedList stack; /** * Create an empty stack. */ public Stack() { this.stack = new LinkedList(); } /** * Add an element to the top of the stack. * * @param element the element to add to the top of the stack */ public void push(E element) { this.stack.addFirst(element); } /** * Remove the top element of the stack. The element is returned * to the client. * * @return the element that was popped from the top of the stack */ public E pop() { return this.stack.removeFirst(); } /** * Returns true if this stack contains no elements. * * @return true if this stack contains no elements */ public boolean isEmpty() { return this.stack.isEmpty(); } }