|
|||||||||
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>
T
- the type of elements contained in this Bag
.public abstract class AbstractBag<T>
An adapter implementation of the Bag
interface. Provides default
implementations of iterator()
and isEmpty()
. Subclasses
need only implement insert(Object)
, extract()
,
size()
, and clear()
.
Constructor Summary | |
---|---|
AbstractBag()
|
Method Summary | |
---|---|
abstract void |
clear()
Removes all elements from the data structure. |
abstract T |
extract()
Extracts an element from the data structure. |
abstract void |
insert(T item)
Inserts an element into the data structure. |
boolean |
isEmpty()
Tests whether the data structure is empty. |
Iterator<T> |
iterator()
The Iterator , unless it is overridden in the concrete subclass,
produces elements in the same order that repeated execution of
extract() would. |
abstract int |
size()
Returns the number of elements contained in the data structure. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public AbstractBag()
Method Detail |
---|
public abstract void insert(T item)
insert
in interface Bag<T>
item
- the element to insertpublic abstract T extract() throws NoSuchElementException
extract
in interface Bag<T>
NoSuchElementException
- if the data structure is emptypublic boolean isEmpty()
isEmpty
in interface Bag<T>
true
if the data structure contains no elementspublic abstract int size()
size
in interface Bag<T>
public abstract void clear()
clear
in interface Bag<T>
public Iterator<T> iterator()
Iterator
, unless it is overridden in the concrete subclass,
produces elements in the same order that repeated execution of
extract()
would. Note that this is not guaranteed by
java.util.Stack
,
for example.
iterator
in interface Iterable<T>
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |