Package dsa.lab03.exercises
Class LinkedStack<Item>
java.lang.Object
dsa.lab03.exercises.LinkedStack<Item>
- Type Parameters:
- Item- the item type
A linked stack.
 
Implements the stack interface by using a singly-linked list.
- 
Constructor SummaryConstructorsConstructorDescriptionConstruct an empty linked stack.LinkedStack(Item... items) Construct a linked stack containing the given items.LinkedStack(Iterable<Item> items) Construct a linked stack containing the given items.
- 
Method SummaryMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.IterableforEach, spliterator
- 
Constructor Details- 
LinkedStackpublic LinkedStack()Construct an empty linked stack.
- 
LinkedStackConstruct a linked stack containing the given items.- Parameters:
- items- the items
 
- 
LinkedStackConstruct a linked stack containing the given items.- Parameters:
- items- the items
 
 
- 
- 
Method Details- 
pushDescription copied from interface:StackPush (insert) the given item onto the top.
- 
popDescription copied from interface:StackPop (remove and return) the given item from the top.- Specified by:
- popin interface- Stack<Item>
- Returns:
- the old top item
- Throws:
- NoSuchElementException- if there's no top item to remove (i.e. if this is empty)
 
- 
topDescription copied from interface:StackGet the item on top.- Specified by:
- topin interface- Stack<Item>
- Returns:
- the top item
- Throws:
- NoSuchElementException- if there's no top item to retrieve (i.e. if this is empty)
 
- 
sizepublic int size()Description copied from interface:ContainerGet the number of contained items.
- 
itemsDescription copied from interface:ContainerGet an iterable that yields each item once.
 
-