java::util::ListQueue Class Reference

Inheritance diagram for java::util::ListQueue:

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

Collaboration graph
java::lang::Objectjava::lang::Interfacejava::util::Queue
[legend]

List of all members.


Detailed Description

The ListQueue class represents a first-in-first-out (FIFO) queue of objects.

It accept class List with operations that allow a list to be treated as a queue. 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

 ListQueue (const Ref< List > &list=0)
 Creates an empty ListQueue.
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 order of list elements are from tail to head

Constructor & Destructor Documentation

java::util::ListQueue::ListQueue ( const Ref< List > &  list = 0  ) 

Creates an empty ListQueue.

The default data structure used is LinkedList.


Member Function Documentation

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

The size of this queue.

Returns:
the number of objects in this queue.

Implements java::util::Queue.

virtual jboolean java::util::ListQueue::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::ListQueue::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::ListQueue::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::ListQueue::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::ListQueue::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::ListQueue::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::ListQueue::clear (  )  [virtual]

Removes all elements from the queue.

Implements java::util::Queue.

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

return the internal list implementation the order of list elements are from tail to head

Implements java::util::Queue.


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