|
|||||||||
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.RandomBag<T>
T
- the type of elements contained in this RandomBag
.public class RandomBag<T>
An implementation of the Bag
interface in which elements are extracted
in a random order.
Constructor Summary | |
---|---|
RandomBag()
|
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 RandomBag()
Method Detail |
---|
public void insert(T item)
insert
in interface Bag<T>
insert
in class AbstractBag<T>
item
- the element to insertpublic T extract() throws NoSuchElementException
extract
in interface Bag<T>
extract
in class AbstractBag<T>
NoSuchElementException
- if the data structure is emptypublic int size()
size
in interface Bag<T>
size
in class AbstractBag<T>
public void clear()
clear
in interface Bag<T>
clear
in class AbstractBag<T>
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |