|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object edu.cornell.cs.cs2110.AbstractBag<T> edu.cornell.cs.cs2110.Stack<T>
T
- the type of elements contained in this Stack
.public class Stack<T>
A LIFO implementation of the Bag
interface.
Constructor Summary | |
---|---|
Stack()
|
Method Summary | |
---|---|
void |
clear()
Removes all elements from the data structure. |
T |
extract()
Extracts an element from the data structure. |
void |
insert(T item)
Inserts an element into the data structure. |
int |
size()
Returns the number of elements contained in the data structure. |
Methods inherited from class edu.cornell.cs.cs2110.AbstractBag |
---|
isEmpty, iterator |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Stack()
Method Detail |
---|
public T extract() throws NoSuchElementException
extract
in interface Bag<T>
extract
in class AbstractBag<T>
NoSuchElementException
- if the data structure is emptypublic void insert(T item)
insert
in interface Bag<T>
insert
in class AbstractBag<T>
item
- the element to insertpublic void clear()
clear
in interface Bag<T>
clear
in class AbstractBag<T>
public int size()
size
in interface Bag<T>
size
in class AbstractBag<T>
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |