Package com.mks.api.util
Class Queue
- java.lang.Object
-
- com.mks.api.util.Queue
-
public class Queue extends java.lang.Object
A simple first-in, first-out queue, avoiding the overhead of a Vector or the double-linked java.util.LinkedList (also supports JDK 1.1).Note that for performance reasons, this implementation is not synchronized. If multiple threads access a Queue object, it must be synchronized externally.
-
-
Constructor Summary
Constructors Constructor Description Queue()
Construct a new Queue object.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
dequeue()
Removes and returns the first element from this queue.void
enqueue(java.lang.Object o)
Appends the specified element to the end of this queue.boolean
isEmpty()
Returns true if the queue is empty.static void
main(java.lang.String[] args)
Performance test of Queue vs.int
size()
Returns the number of elements in the queue.
-
-
-
Method Detail
-
enqueue
public void enqueue(java.lang.Object o)
Appends the specified element to the end of this queue.- Parameters:
o
- element to be appended to this queue.
-
dequeue
public java.lang.Object dequeue()
Removes and returns the first element from this queue.- Returns:
- the first element from this queue.
- Throws:
java.util.NoSuchElementException
- if this queue is empty.
-
isEmpty
public boolean isEmpty()
Returns true if the queue is empty.
-
size
public int size()
Returns the number of elements in the queue.
-
main
public static void main(java.lang.String[] args)
Performance test of Queue vs. Vector.
-
-