|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectm865.datastructures.AbstractQueue
m865.datastructures.BalkingQueue
This class implements a balking queue, which is an extension of an AbstractQueue that implements all the remove methods of the Collection interface. It uses the java.util.LinkedList to store the objects in the queue.
Nested Class Summary | |
class |
BalkingQueue.BalkingQueueIterator
An iterator for a BalkingQueue. |
Field Summary | |
protected java.util.LinkedList |
list
The objects in the queue are stored in this Linked List. |
Fields inherited from class m865.datastructures.AbstractQueue |
hash |
Constructor Summary | |
|
BalkingQueue()
The default constructor. |
|
BalkingQueue(java.util.Collection c)
Constructs a queue which is initialized with the objects in the specified collection |
protected |
BalkingQueue(int hash,
java.util.LinkedList list)
Constructs a queue with a specified hash code and a clone of the specified LinkedList. |
Method Summary | |
void |
clear()
Removes all the objects from this queue. |
java.lang.Object |
clone()
The Cloneable Interface indicates that the clone method, which is inherited from Object, is implemented so that a true clone (a true and independent copy) of the object is returned. |
java.lang.Object |
dequeue()
Removes and returns the object at the beginning of the queue. |
void |
enqueue(java.lang.Object obj)
Appends an object to the end of the queue. |
boolean |
isEmpty()
Determines whether the queue is empty. |
java.util.Iterator |
iterator()
A factory method which returns an Iterator to the collection in this queue. |
static void |
main(java.lang.String[] args)
This main method tests the BalkingQueue class to insure that the elementary functions are correct. |
java.lang.Object |
peek()
Returns the object at the beginning of the queue. |
boolean |
remove(java.lang.Object obj)
Removes a single instance of the specified element from this collection, if it is present |
boolean |
removeAll(java.util.Collection c)
Insures that each element of the specified collection is removed from the the balking queue. |
boolean |
retainAll(java.util.Collection c)
Removes all the elements of the balking queue that are not contained in the specified collection. |
int |
size()
Determines the size of this balking queue. |
java.lang.String |
toString()
List the objects in this balking queue |
Methods inherited from class m865.datastructures.AbstractQueue |
add, addAll, contains, containsAll, downdateHashCode, equals, hashCode, toArray, toArray, updateHashCode |
Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
protected java.util.LinkedList list
Constructor Detail |
public BalkingQueue()
public BalkingQueue(java.util.Collection c)
c
- the collection of objects to be initially enqueued
onto this queue.protected BalkingQueue(int hash, java.util.LinkedList list)
hash
- the hash codelist
- the linked list containing the objects in the queue.Method Detail |
public void enqueue(java.lang.Object obj)
enqueue
in class AbstractQueue
obj
- the object to be appended to the end of the queue.public java.lang.Object dequeue()
dequeue
in class AbstractQueue
public java.lang.Object peek()
peek
in class AbstractQueue
public void clear()
public java.lang.Object clone()
public boolean isEmpty()
isEmpty
in interface java.util.Collection
isEmpty
in class AbstractQueue
public java.util.Iterator iterator()
public boolean remove(java.lang.Object obj)
remove
in interface java.util.Collection
remove
in class AbstractQueue
obj
- the object to be removed.
public boolean removeAll(java.util.Collection c)
removeAll
in interface java.util.Collection
removeAll
in class AbstractQueue
c
- the specified collection
public boolean retainAll(java.util.Collection c)
retainAll
in interface java.util.Collection
retainAll
in class AbstractQueue
c
- the specified collection
public int size()
public java.lang.String toString()
toString
in class AbstractQueue
public static void main(java.lang.String[] args)
args
- optional command line arguments which will be ignored.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |