net.sf.zig_project.gpl.common.queue
Interface LinearQueue

All Superinterfaces:
Queue
All Known Subinterfaces:
ConsistantQueue
All Known Implementing Classes:
ArrayQueueTest.CheckedArrayQueue, LinearQueueBase, LinearQueueTest.CheckedDuplexQueue, LinearQueueTest.CheckedFifoQueue

public interface LinearQueue
extends Queue

Defines a Queue with two ends. Elements are either catagorized at the beginning or at the end of the Queue.

Version:
January 20, 2005
Author:
Frank Ziglar

Method Summary
 void addFirst(Object o)
          Adds an Object to the beginning of the Queue.
 void addLast(Object o)
          Adds an Object to the end of the Queue.
 void appendFlat(LinearQueue q)
          Moves the contents of q to the end of this Queue.
 void appendUnrolled(LinearQueue q)
          Moves the contents of q to the end of this Queue.
 Object peekFirst()
          Retrieves the first Object in the Queue.
 Object peekLast()
          Retrieves the last Object in the Queue.
 void prependFlat(LinearQueue q)
          Moves the contents of q to the beginning of this Queue.
 void prependUnrolled(LinearQueue q)
          Moves the contents of q to the beginning of this Queue.
 Object removeFirst()
          Removes the first Object in the Queue.
 Object removeLast()
          Removes the last Object in the Queue.
 
Methods inherited from interface net.sf.zig_project.gpl.common.queue.Queue
clear, contains, elements, isEmpty, remove
 

Method Detail

addFirst

public void addFirst(Object o)
Adds an Object to the beginning of the Queue.

Parameters:
o - the Object to add
Throws:
NullPointerException - if o==null and this Queue does not support null Objects.

addLast

public void addLast(Object o)
Adds an Object to the end of the Queue.

Parameters:
o - the Object to add
Throws:
NullPointerException - if o==null and this Queue does not support null Objects.

peekFirst

public Object peekFirst()
Retrieves the first Object in the Queue. This does not actually remove the Object from the Queue.

Returns:
the first Object in the Queue

peekLast

public Object peekLast()
Retrieves the last Object in the Queue. This does not actually remove the Object from the Queue.

Returns:
the last Object in the Queue

removeFirst

public Object removeFirst()
Removes the first Object in the Queue.

Returns:
the previous first Object in the Queue, or null if the Queue was empty

removeLast

public Object removeLast()
Removes the last Object in the Queue.

Returns:
the previous last Object in the Queue, or null if the Queue was empty

prependUnrolled

public void prependUnrolled(LinearQueue q)
Moves the contents of q to the beginning of this Queue. The first element of q is placed before the first element of this Queue, and the first element of this Queue becomes what was the last element of q.

With two Queues of contents q1="a, b, c" and q2="x, y, z", then q1.prependUnrolled(q2); would result in q1=="z, y, x, a, b, c", and q2==""

Throws:
IllegalArgumentException - if q==this

prependFlat

public void prependFlat(LinearQueue q)
Moves the contents of q to the beginning of this Queue. The last element of q is placed before the first element of this Queue, and the first element of this Queue will become the first element of q

With two Queues of contents q1="a, b, c" and q2="x, y, z", then q1.prependFlat(q2); would result in q1=="x, y, z, a, b, c", and q2==""

Throws:
IllegalArgumentException - if q==this

appendFlat

public void appendFlat(LinearQueue q)
Moves the contents of q to the end of this Queue. The first element of q is placed after the last element of this queue, and the last element of this Queue will become the last element of q.

With two Queues of contents q1="a, b, c" and q2="x, y, z", then q1.appendFlat(q2); would result in q1=="a, b, c, x, y, z", and q2==""

Throws:
IllegalArgumentException - if q==this

appendUnrolled

public void appendUnrolled(LinearQueue q)
Moves the contents of q to the end of this Queue. The last element of q is placed after the last element of this queue, and the last element of this Queue will become the first element of q.

With two Queues of contents q1="a, b, c" and q2="x, y, z", then q1.appendUnrolled(q2); would result in q1=="a, b, c, z, y, x", and q2==""

Throws:
IllegalArgumentException - if q==this