Pig Latin Problem Set Javadocs

cs101.util.queue
Class DefaultQueue

java.lang.Object
  extended bycs101.util.queue.DefaultQueue
All Implemented Interfaces:
Queue

public class DefaultQueue
extends java.lang.Object
implements Queue

Default Queue class. Allows insertion/deletion at either end. Throws EmptyQueueException in some situations, but EmptyQueueException is a subclass of RuntimeException, so you don't have to protect Queue access with try/catch blocks.

Copyright (c) 1998 Massachusetts Institute of Technology

Version:
$Id: DefaultQueue.java,v 1.2 2003/09/23 14:46:57 gus Exp $
Author:
Todd C. Parnell, tparnell@ai.mit.edu
See Also:
EmptyQueueException

Field Summary
 
Fields inherited from interface cs101.util.queue.Queue
BACK, FRONT
 
Constructor Summary
DefaultQueue()
          Creates a new, empty Queue
DefaultQueue(java.lang.Object obj)
          Creates a new Queue contining obj as the only element
 
Method Summary
 java.lang.Object dequeue()
          Removes and returns the Object at the tail of the queue.
 java.lang.Object dequeue(int end)
          Removes and returns the Object at the specified end of the queue.
 java.util.Enumeration elements()
          Returns an Enumeration of the Objects in the queue.
 void enqueue(java.lang.Object obj)
          Puts obj into the front the queue.
 void enqueue(java.lang.Object obj, int end)
          Puts obj into the specified end of the queue.
 boolean isEmpty()
          Tests whether the queue is empty.
 java.lang.Object peek()
          Gets the tail object from the queue without removing it.
 java.lang.Object peek(int end)
          Gets the object from the specified end of the queue without removing it.
 int size()
          Returns the number of elements in this.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DefaultQueue

public DefaultQueue()
Creates a new, empty Queue


DefaultQueue

public DefaultQueue(java.lang.Object obj)
Creates a new Queue contining obj as the only element

Method Detail

size

public int size()
Returns the number of elements in this.

Specified by:
size in interface Queue

peek

public java.lang.Object peek()
Gets the tail object from the queue without removing it.

Specified by:
peek in interface Queue

peek

public java.lang.Object peek(int end)
Gets the object from the specified end of the queue without removing it.

Specified by:
peek in interface Queue

enqueue

public void enqueue(java.lang.Object obj)
Puts obj into the front the queue.

Specified by:
enqueue in interface Queue

enqueue

public void enqueue(java.lang.Object obj,
                    int end)
Puts obj into the specified end of the queue.

Specified by:
enqueue in interface Queue

dequeue

public java.lang.Object dequeue()
Removes and returns the Object at the tail of the queue.

Specified by:
dequeue in interface Queue

dequeue

public java.lang.Object dequeue(int end)
Removes and returns the Object at the specified end of the queue.

Specified by:
dequeue in interface Queue

isEmpty

public boolean isEmpty()
Tests whether the queue is empty.

Specified by:
isEmpty in interface Queue

elements

public java.util.Enumeration elements()
Returns an Enumeration of the Objects in the queue.

Note: Do not modify the queue while enumerating--unpredictable behavior may result.

Specified by:
elements in interface Queue
See Also:
Enumeration

toString

public java.lang.String toString()

Pig Latin Problem Set Javadocs