net.sf.zig_project.gpl.common.queue
Class LinearQueueBase

java.lang.Object
  extended bynet.sf.zig_project.gpl.common.queue.LinearQueueBase
All Implemented Interfaces:
LinearQueue, Queue
Direct Known Subclasses:
ArrayQueue, LinkedQueue

public abstract class LinearQueueBase
extends Object
implements LinearQueue

Abstract base class for LinearQueues. This class defines a few simple default operations required by LinearQueues.

Version:
January 20, 2005
Author:
Frank Ziglar

Constructor Summary
LinearQueueBase()
           
 
Method Summary
 void add(Object o)
          Adds a single Object to the Queue.
 void addSet(Enumeration e)
          Adds an entire Enumeration of elements to the Queue.
 void appendFlat(LinearQueue q)
          Moves the contents of q to the end of this Queue.
 void appendFlat(OrderedQueue q)
           
 void appendUnrolled(LinearQueue q)
          Moves the contents of q to the end of this Queue.
 void appendUnrolled(OrderedQueue q)
           
protected  void bulkMoveTest(LinearQueue q)
           
 void prependFlat(LinearQueue q)
          Moves the contents of q to the beginning of this Queue.
 void prependFlat(OrderedQueue q)
           
 void prependUnrolled(LinearQueue q)
          Moves the contents of q to the beginning of this Queue.
 void prependUnrolled(OrderedQueue q)
           
 String toString()
          General purpose String representation.
 boolean transferTo(Object o, GenericBlockingQueue q)
          Transfers an Object out of this Queue and into another.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface net.sf.zig_project.gpl.common.queue.LinearQueue
addFirst, addLast, peekFirst, peekLast, removeFirst, removeLast
 
Methods inherited from interface net.sf.zig_project.gpl.common.queue.Queue
clear, contains, elements, isEmpty, remove
 

Constructor Detail

LinearQueueBase

public LinearQueueBase()
Method Detail

add

public void add(Object o)
Adds a single Object to the Queue. The Object is added to the end of the Queue by default.


addSet

public void addSet(Enumeration e)
Adds an entire Enumeration of elements to the Queue. The default implementation is to add each object from the enumeration to the Queue one by one, but subclasses may override this method to provide a more efficient implementation. After normal completion of this method, the Enumeration will be exhausted of elements.


transferTo

public boolean transferTo(Object o,
                          GenericBlockingQueue q)
Transfers an Object out of this Queue and into another. By default, this simply removes the first copy of o from this queue, and then adds it to q.


toString

public String toString()
General purpose String representation. Lists the contents of this Queue as a single line (assuming each element only occupies one line).

Returns:
a String representation of the contents of the Queue

bulkMoveTest

protected void bulkMoveTest(LinearQueue q)

prependUnrolled

public void prependUnrolled(LinearQueue q)
Moves the contents of q to the beginning of this Queue.

This method will default to performing a First to First move. If an Exception is thrown during the move, it will attempt to rollback both Queues to their previous state before rethrowing the Exception.

Specified by:
prependUnrolled in interface LinearQueue
Throws:
RuntimeException - if the move could not be completed
RollbackError - if neither the move or a rollback could be completed

prependFlat

public void prependFlat(LinearQueue q)
Moves the contents of q to the beginning of this Queue.

This method will default to performing a Last to First move. If an Exception is thrown during the move, it will attempt to rollback both Queues to their previous state before rethrowing the Exception.

Specified by:
prependFlat in interface LinearQueue
Throws:
RuntimeException - if the move could not be completed
RollbackError - if neither the move or a rollback could be completed

appendFlat

public void appendFlat(LinearQueue q)
Moves the contents of q to the end of this Queue.

This method will default to performing a First to Last move. If an Exception is thrown during the move, it will attempt to rollback both Queues to their previous state before rethrowing the Exception.

Specified by:
appendFlat in interface LinearQueue
Throws:
RuntimeException - if the move could not be completed
RollbackError - if neither the move or a rollback could be completed

appendUnrolled

public void appendUnrolled(LinearQueue q)
Moves the contents of q to the end of this Queue.

This method will default to performing a Last to Last move. If an Exception is thrown during the move, it will attempt to rollback both Queues to their previous state before rethrowing the Exception.

Specified by:
appendUnrolled in interface LinearQueue
Throws:
RuntimeException - if the move could not be completed
RollbackError - if neither the move or a rollback could be completed

appendFlat

public void appendFlat(OrderedQueue q)

appendUnrolled

public void appendUnrolled(OrderedQueue q)

prependUnrolled

public void prependUnrolled(OrderedQueue q)

prependFlat

public void prependFlat(OrderedQueue q)