All Packages Class Hierarchy This Package Previous Next Index
Class com.ibm.beans.util.PriorityQueue
java.lang.Object
|
+----com.ibm.beans.util.PriorityQueue
- public class PriorityQueue
- extends Object
- implements Cloneable, Serializable
A PriorityQueue is a collection class that keeps the objects ordered.
Ordering is based on the methods supplied by the Comparable
object supplied during construction. The java.lang.Object.equals() method is
not used in the ordering of the priority queue.
Priority queues can be implemented in different ways. This implementation
assumes
that enumeration over the queue occurs more frequently than
additions or deletions from the queue. This priority
queue orders its contents during insertion
and deletion, making enumeration faster.
The PriorityQueue has the highest priority elements at the top
of the queue and the lowest priority elements at the bottom. This is
purely a numerical comparison: a priority of 10 is greater than a
priority of 1. In this case, a priority of 1 is at
end of the priority queue.
-
PriorityQueue(Comparable)
- Constructs a PriorityQueue instance.
-
clone()
- Clones this priority queue.
-
contains(Object)
- Determines if an element is a member of this priority queue.
-
elements()
- Gets an enumeration of the elements in this priority queue.
-
isEmpty()
- Checks to see if this priority queue is empty.
-
pop()
- Removes the top object in this priority queue.
-
push(Object)
- Adds the specified object to this priority queue.
-
removeElement(Object)
- Removes the first occurrence of the specified element from this
priority queue.
-
seeBottom()
- Determines the last element in this priority queue.
-
seeTop()
- Determines the first element in this priority queue.
-
size()
- Gets the number of elements in this priority queue.
-
toString()
- Converts this priority queue to a String.
PriorityQueue
public PriorityQueue(Comparable x)
- Constructs a PriorityQueue instance.
- Parameters:
- x - The Comparable to be used to order the elements in this
priority queue.
isEmpty
public final boolean isEmpty()
- Checks to see if this priority queue is empty.
- Returns:
-
true
if this priority queue is empty;
false
otherwise.
size
public final int size()
- Gets the number of elements in this priority queue.
- Returns:
- The number of elements in this priority queue.
seeTop
public final synchronized Object seeTop()
- Determines the first element in this priority queue.
- Returns:
- The first element in this priority queue, if this priority queue
is not empty. Otherwise it returns
null
.
seeBottom
public final synchronized Object seeBottom()
- Determines the last element in this priority queue.
- Returns:
- The last element in this priority queue, if this priority queue
is not empty. Otherwise it returns
null
.
push
public final synchronized void push(Object x)
- Adds the specified object to this priority queue.
- Parameters:
- x - The object to be added to this priority queue.
pop
public final synchronized Object pop()
- Removes the top object in this priority queue.
- Returns:
- The object removed from this priority queue.
removeElement
public final synchronized boolean removeElement(Object obj)
- Removes the first occurrence of the specified element from this
priority queue.
- Parameters:
- obj - The object to be removed.
- Returns:
-
true
if the element was actually removed;
false
otherwise.
contains
public final boolean contains(Object x)
- Determines if an element is a member of this priority queue.
- Parameters:
- x - The element to try to find in this priority queue.
- Returns:
-
true
if the element is a member of this
priority queue; false
otherwise.
elements
public final synchronized Enumeration elements()
- Gets an enumeration of the elements in this priority queue.
Use the Enumeration methods on
the returned object to fetch the elements sequentially.
- Returns:
- An enumeration of the components of this priority queue.
toString
public final synchronized String toString()
- Converts this priority queue to a String. This method is useful
for debugging.
- Returns:
- A String representation of this priority queue.
- Overrides:
- toString in class Object
clone
public synchronized Object clone()
- Clones this priority queue. The elements contained in this
priority queue are not cloned.
- Overrides:
- clone in class Object
All Packages Class Hierarchy This Package Previous Next Index