Class Queue.QImpl
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class Queue.QImpl

java.lang.Object
   |
   +----Queue.QImpl

public class QImpl
extends Object
implements Queue
Class QImpl implements the interface Queue. Operations on the queue interface are synchronized to allow concurrent access.
See Also:
Queue

Variable Index

 o head_node
refers to the first element
 o num_elem
keep track of queue size
 o tail_node
refers to the last element

Constructor Index

 o QImpl()
Constructor, creates an empty queue.

Method Index

 o clone()
Returns a shallow copy of the queue.
 o elements()
Returns an enumeration of the elements in the queue.
 o firstElement()
Returns the first element of the queue without removing the element.
 o insertFirst(Object)
Insert the specified element into the front of the queue.
 o insertLast(Object)
Insert the specified element into the back of the queue.
 o lastElement()
Returns the last element of the queue without removing the element.
 o removeFirst()
Remove and return an element from the front of the queue.
 o removeLast()
Remove and return an element from the back of the queue.
 o size()
Returns the number of elements in the queue.

Variables

 o num_elem
  protected int num_elem
keep track of queue size
 o head_node
  protected QNodeImpl head_node
refers to the first element
 o tail_node
  protected QNodeImpl tail_node
refers to the last element

Constructors

 o QImpl
  public QImpl()
Constructor, creates an empty queue.

Methods

 o lastElement
  public synchronized Object lastElement() throws NoSuchElementException
Returns the last element of the queue without removing the element.
Returns:
the last element
 o firstElement
  public synchronized Object firstElement() throws NoSuchElementException
Returns the first element of the queue without removing the element.
Returns:
the first element
 o insertFirst
  public synchronized void insertFirst(Object elem)
Insert the specified element into the front of the queue.
Parameters:
elem - element to be inserted
 o insertLast
  public synchronized void insertLast(Object elem)
Insert the specified element into the back of the queue.
Parameters:
elem - element to be inserted
 o removeFirst
  public synchronized Object removeFirst() throws NoSuchElementException
Remove and return an element from the front of the queue.
Returns:
the element at the front of the queue
Throws: NoSuchElementException
thrown when there are no elements in the queue
 o removeLast
  public synchronized Object removeLast() throws NoSuchElementException
Remove and return an element from the back of the queue.
Returns:
the element at the back of the queue
Throws: NoSuchElementException
thrown when there are no elements in the queue
 o size
  public synchronized int size()
Returns the number of elements in the queue.
 o elements
  public synchronized Enumeration elements()
Returns an enumeration of the elements in the queue.
Returns:
the enumeration
See Also:
Enumeration
 o clone
  public synchronized Object clone()
Returns a shallow copy of the queue.
Overrides:
clone in class Object
See Also:
clone

All Packages  Class Hierarchy  This Package  Previous  Next  Index