java::util::PriorityQueue Class Reference

Inheritance diagram for java::util::PriorityQueue:

Inheritance graph
java::lang::Objectjava::lang::Interfacejava::util::Queue
[legend]
Collaboration diagram for java::util::PriorityQueue:

Collaboration graph
java::lang::Objectjava::lang::Interfacejava::lang::ObjectRefjava::util::Queuejava::lang::Comparable
[legend]

List of all members.


Detailed Description

The PriorityQueue class represents a priority queue of objects.

The usual enqueue and dequeue operations are provided, as well as a method to peek at the head item on the queue, a method to test for whether the queue isEmpty, and a method to search the queue for an item and discover how far it is from the head.

When a queue is first created, it contains no items.

Author:
Yuh-Jye Chang
Version:
1.25, 12/03/01
Since:
DK1.0

Public Member Functions

 PriorityQueue (const Ref< Comparator > &comp=0)
 Creates an empty PriorityQueue, The comparator will determine the order of the object.
virtual Ref< Comparatorcomparator () const
 Returns the comparator associated with this priority queue, or null if it uses its objects' natural ordering.
virtual jint size () const
 The size of this queue.
virtual jboolean isEmpty () const
 Tests if this queue is empty.
virtual ObjectRef enqueue (const ObjectRef &item)
 Pushes an item onto the tail of this queue.
virtual ObjectRef dequeue ()
 Removes the object at the head of this queue and returns that object as the value of this function.
virtual ObjectRef requeue ()
 Removes the head object then pushes it onto the tail of this queue.
virtual ObjectRef head () const
 Looks at the object at the head of this queue without removing it from the queue.
virtual jint search (const ObjectRef &o) const
 Returns the 1-based position where an object is on this queue.
virtual void clear ()
 Removes all elements from the queue.
virtual Ref< ListgetInternalList () const
 return the internal list implementation the list elements start from head
virtual String toString () const
 Returns a string representation of the object.

Constructor & Destructor Documentation

java::util::PriorityQueue::PriorityQueue ( const Ref< Comparator > &  comp = 0  ) 

Creates an empty PriorityQueue, The comparator will determine the order of the object.

When comp is null, head will return the smallest object of the objects' natual order.


Member Function Documentation

virtual Ref<Comparator> java::util::PriorityQueue::comparator (  )  const [virtual]

Returns the comparator associated with this priority queue, or null if it uses its objects' natural ordering.

Returns:
the comparator associated with this priority queue, or null if it uses its objects' natural ordering.

virtual jint java::util::PriorityQueue::size (  )  const [virtual]

The size of this queue.

Returns:
the number of objects in this queue.

Implements java::util::Queue.

virtual jboolean java::util::PriorityQueue::isEmpty (  )  const [virtual]

Tests if this queue is empty.

Returns:
true if and only if this queue contains no items; false otherwise.

Implements java::util::Queue.

virtual ObjectRef java::util::PriorityQueue::enqueue ( const ObjectRef item  )  [virtual]

Pushes an item onto the tail of this queue.

Parameters:
item the item to be pushed onto this queue.
Returns:
the item argument.
See also:
java.util.Vector::addElement

Implements java::util::Queue.

virtual ObjectRef java::util::PriorityQueue::dequeue (  )  [virtual]

Removes the object at the head of this queue and returns that object as the value of this function.

Returns:
The object at the head of this stack (the last item of the Vector object).
Exceptions:
NoSuchElementException if this stack is empty.

Implements java::util::Queue.

virtual ObjectRef java::util::PriorityQueue::requeue (  )  [virtual]

Removes the head object then pushes it onto the tail of this queue.

Usually happens when the head object was modified.

Returns:
the head object that been requeue.
See also:
java.util.Vector::addElement

Implements java::util::Queue.

virtual ObjectRef java::util::PriorityQueue::head (  )  const [virtual]

Looks at the object at the head of this queue without removing it from the queue.

Returns:
the object at the head of this queue.
Exceptions:
NoSuchElementException if this queue is empty.

Implements java::util::Queue.

virtual jint java::util::PriorityQueue::search ( const ObjectRef o  )  const [virtual]

Returns the 1-based position where an object is on this queue.

If the object o occurs as an item in this queue, this method returns the distance from the head of the queue of the occurrence nearest the head of the queue; the rear item on the queue is considered to be at distance 1. The equals method is used to compare o to the items in this queue.

Parameters:
o the desired object.
Returns:
the 1-based position from the head of the queue where the object is located; the return value -1 indicates that the object is not on the queue.

Implements java::util::Queue.

virtual void java::util::PriorityQueue::clear (  )  [virtual]

Removes all elements from the queue.

Implements java::util::Queue.

virtual Ref<List> java::util::PriorityQueue::getInternalList (  )  const [virtual]

return the internal list implementation the list elements start from head

Implements java::util::Queue.

virtual String java::util::PriorityQueue::toString (  )  const [virtual]

Returns a string representation of the object.

In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method.

The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `</code>', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of: <blockquote>

 getClass().getName() + '@' + Integer.toHexString(hashCode())
 
</blockquote>

Returns:
a string representation of the object.

Reimplemented from java::lang::Object.


The documentation for this class was generated from the following file:
Generated on Fri May 16 11:56:50 2008 for CrossPlatformJavaLikeC++API by  doxygen 1.5.3