oracle.cle.util
Class Queue
java.lang.Object
|
+--oracle.cle.util.Queue
- public class Queue
- extends java.lang.Object
A simple Queue datastructure implementation.
We might want to enhance this with a default
size (like Hashtables do).
Constructor Summary |
Queue()
|
Method Summary |
java.lang.Object |
dequeue()
Return and remove the first element that was enqueued. |
boolean |
enqueue(java.lang.Object element)
Enqueue the specified element and return true if successful,
false otherwise. |
boolean |
isEmpty()
|
static void |
main(java.lang.String[] args)
Tests the Queue class by enqueueing and dequeueing 10 Integers. |
java.lang.Object |
peek()
The first element that was enqueud, but do not dequeue it. |
java.lang.Object |
peek(int entriesToPeekThrough)
The nth element that was enqueud, but do not dequeue it. |
int |
size()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Queue
public Queue()
enqueue
public boolean enqueue(java.lang.Object element)
- Enqueue the specified element and return true if successful,
false otherwise.
dequeue
public java.lang.Object dequeue()
- Return and remove the first element that was enqueued.
Returns null on error.
peek
public java.lang.Object peek()
- The first element that was enqueud, but do not dequeue it.
peek
public java.lang.Object peek(int entriesToPeekThrough)
The nth element that was enqueud, but do not dequeue it.
Zero relative, so first enque was 0th element enqueued, etc...
Returns null if out of bounds or error.
size
public int size()
isEmpty
public boolean isEmpty()
main
public static void main(java.lang.String[] args)
- Tests the Queue class by enqueueing and dequeueing 10 Integers.
Copyright © 2003 ORACLE Corp. All Rights Reserved.