Stack - public boolean isEmpty() { return list.isEmpty(); }...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
/** Park Patel masc0155 **/ import java.util.Iterator; public class Stack<E> implements Iterable<E> { private ListADT<E> list; public Stack() { list = new LinkedListDS<E>(); } private class Node { private E obj; private Node next; } public void makeEmpty() { list.makeEmpty(); } public boolean contains(E obj) { return (list.contains(obj)); }
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: public boolean isEmpty() { return list.isEmpty(); } public int size() { return list.size(); } public void push(E obj) { list.addFirst(obj); } public E pop() { return (list.removeFirst()); } public E peek() { return (list.peekFirst()); } public Iterator&lt;E&gt; iterator() { return list.iterator(); } }...
View Full Document

Ask a homework question - tutors are online