Class IntQueue

java.lang.Object
  extended byIntQueue

public class IntQueue
extends java.lang.Object

This class implements queues of integers as linked lists from the class IntList. Insertions are made at the rear and deletions at the front. The link is from front to rear.


Constructor Summary
IntQueue()
           
 
Method Summary
 void add(int val)
          Adds the integer val to the queue.
 void add(IntList l)
          Adds the list l at the rear of the queue.
 IntQueue append(IntQueue x)
          Concatenates the current queue and the queue s.
 IntQueue concat(IntQueue x)
          A variant of append().
 boolean isEmpty()
          Returns true if the queue is empty.
 int lastVal()
          Returns the last element of the queue.
 IntList remove()
          Removes the first element of the queue.
 void removeAll()
          Empties the queue.
 int removeVal()
          Returns the penultimate value.
 void seizeAll(IntQueue s)
          Adds all the elements of the queue s and empties s.
 java.lang.String show(java.lang.String name)
           
 int size()
          Returns the size of the queue.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IntQueue

public IntQueue()
Method Detail

add

public void add(int val)
Adds the integer val to the queue.

Parameters:
val - an integer.

add

public void add(IntList l)
Adds the list l at the rear of the queue.

Parameters:
l - a linked list of integers.

remove

public IntList remove()
Removes the first element of the queue. Returns null if the queue is empty.

Returns:
the resulting queue.

removeAll

public void removeAll()
Empties the queue.


isEmpty

public boolean isEmpty()
Returns true if the queue is empty.


size

public int size()
Returns the size of the queue.


lastVal

public int lastVal()
Returns the last element of the queue.


removeVal

public int removeVal()
Returns the penultimate value.


seizeAll

public void seizeAll(IntQueue s)
Adds all the elements of the queue s and empties s.


toString

public java.lang.String toString()

show

public java.lang.String show(java.lang.String name)

append

public IntQueue append(IntQueue x)
Concatenates the current queue and the queue s.

Returns:
the resulting queue.

concat

public IntQueue concat(IntQueue x)
A variant of append().