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

java.lang.Object
  extended bynet.sf.zig_project.gpl.common.queue.LinearOrderedQueue
All Implemented Interfaces:
GenericBlockingQueue, GenericQueue, OrderedBlockingQueue, OrderedQueue, Queue
Direct Known Subclasses:
FifoOrderedQueue, LifoOrderedQueue

public abstract class LinearOrderedQueue
extends Object
implements GenericQueue

Adapts a LinearQueue into an OrderedQueue

Version:
January 20, 2005
Author:
Frank Ziglar

Field Summary
protected  LinearQueue queue
           
 
Constructor Summary
LinearOrderedQueue(LinearQueue q)
           
 
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.
protected abstract  void appendFlatTo(LinearQueue q)
           
protected abstract  void appendUnrolledTo(LinearQueue q)
           
 void clear()
          Empties the Queue.
 boolean contains(Object o)
          Determines if the Queue contains a copy of the specified Object.
 Enumeration elements()
          Retrieves a list of the elements currently in the queue in a form suitable to enumerate over.
 boolean isEmpty()
          Determines if the Queue is empty.
protected abstract  void prependFlatTo(LinearQueue q)
           
protected abstract  void prependUnrolledTo(LinearQueue q)
           
 Object remove(Object o)
          Removes the first found element that is equal to o from the queue.
 String toString()
           
 boolean transferTo(Object o, GenericBlockingQueue q)
          Transfers an Object, if it exists, 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.OrderedBlockingQueue
peekNext, removeNext
 
Methods inherited from interface net.sf.zig_project.gpl.common.queue.OrderedQueue
removeNext
 

Field Detail

queue

protected final LinearQueue queue
Constructor Detail

LinearOrderedQueue

public LinearOrderedQueue(LinearQueue q)
Method Detail

clear

public void clear()
Description copied from interface: Queue
Empties the Queue. All elements are cleared out, and the Queue will be empty after this call.

Specified by:
clear in interface Queue

add

public void add(Object o)
Description copied from interface: GenericBlockingQueue
Adds a single Object to the Queue.

Specified by:
add in interface GenericBlockingQueue
Parameters:
o - the Object to be added

isEmpty

public boolean isEmpty()
Description copied from interface: Queue
Determines if the Queue is empty. An empty queue contains no elements.

Specified by:
isEmpty in interface Queue
Returns:
true only if the Queue is empty

elements

public Enumeration elements()
Description copied from interface: Queue
Retrieves a list of the elements currently in the queue in a form suitable to enumerate over. Operations on the Enumeration after this queue has been modified are not anticipated, and may cause unforseen problems.

Specified by:
elements in interface Queue
Returns:
an Enumeration of the elements in the queue

addSet

public void addSet(Enumeration e)
Description copied from interface: GenericBlockingQueue
Adds an entire Enumeration of elements to the Queue.

Specified by:
addSet in interface GenericBlockingQueue
Parameters:
e - a enumerable set of elements

toString

public String toString()

transferTo

public boolean transferTo(Object o,
                          GenericBlockingQueue q)
Description copied from interface: GenericBlockingQueue
Transfers an Object, if it exists, out of this Queue and into another. Generally, this method is designed for priority Queues, where the main queue must promote an Object from one Queue to another.

Specified by:
transferTo in interface GenericBlockingQueue
Parameters:
o - a copy of the Object to transfer
q - the Queue to transfer the copy to
Returns:
true only if a copy was found and transfered, otherwise false if no copy was found, and no element was added to the target Queue

remove

public Object remove(Object o)
Description copied from interface: Queue
Removes the first found element that is equal to o from the queue.

Specified by:
remove in interface Queue
Parameters:
o - a copy of the Object to be removed
Returns:
the first copy of o found, or null if no copy was found.

contains

public boolean contains(Object o)
Description copied from interface: Queue
Determines if the Queue contains a copy of the specified Object.

Specified by:
contains in interface Queue
Parameters:
o - an Object to look for copies of
Returns:
true if at least one copy of o was found in the queue

appendFlatTo

protected abstract void appendFlatTo(LinearQueue q)

appendUnrolledTo

protected abstract void appendUnrolledTo(LinearQueue q)

prependFlatTo

protected abstract void prependFlatTo(LinearQueue q)

prependUnrolledTo

protected abstract void prependUnrolledTo(LinearQueue q)