algoanim.primitives
Class VisualQueue<T>

java.lang.Object
  extended by algoanim.primitives.Primitive
      extended by algoanim.primitives.VisualQueue<T>
Direct Known Subclasses:
ArrayBasedQueue, ConceptualQueue, ListBasedQueue

public abstract class VisualQueue<T>
extends Primitive

Base abstract class for all the (FIFO-)queues in animalscriptapi.primitives.
VisualQueue represents the common visual features of all the subclasses and manges the actual data using an internal java.util.LinkedList.
The stored objects are of the generic data type T, so it is generally possible to use VisualQueue with any objects.

Author:
Dima Vronskyi
See Also:
ConceptualQueue, ArrayBasedQueue, ListBasedQueue

Field Summary
 
Fields inherited from class algoanim.primitives.Primitive
gen
 
Constructor Summary
VisualQueue(GeneratorInterface g, Node upperLeftCorner, java.util.List<T> content, java.lang.String name, DisplayOptions display, QueueProperties qp)
          Constructor of the VisualQueue.
 
Method Summary
 T dequeue()
          Removes and returns the first element of the queue.
 void enqueue(T elem)
          Adds the element elem as the last element to the end of the queue.
 T front()
          Retrieves (without removing) the first element of the queue.
 java.util.List<T> getInitContent()
          Returns the initial content of the queue.
 QueueProperties getProperties()
          Returns the properties of the queue.
 java.util.LinkedList<T> getQueue()
          Returns the internal queue as java.util.LinkedList.
 Node getUpperLeft()
          Returns the upper left corner of the queue.
 boolean isEmpty()
          Tests if the queue is empty.
 void setName(java.lang.String newName)
          Sets the name of this Primitive.
 T tail()
          Retrieves (without removing) the last element of the queue.
 
Methods inherited from class algoanim.primitives.Primitive
changeColor, exchange, getDisplayOptions, getName, hide, hide, moveBy, moveTo, moveVia, rotate, rotate, show, show
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VisualQueue

public VisualQueue(GeneratorInterface g,
                   Node upperLeftCorner,
                   java.util.List<T> content,
                   java.lang.String name,
                   DisplayOptions display,
                   QueueProperties qp)
Constructor of the VisualQueue.

Parameters:
g - the appropriate code Generator.
upperLeftCorner - the upper left corner of this VisualQueue.
content - the initial content of the VisualQueue, consisting of the elements of the generic type T.
name - the name of this VisualQueue.
display - [optional] the DisplayOptions of this VisualQueue.
qp - [optional] the properties of this VisualQueue.
Method Detail

enqueue

public void enqueue(T elem)
Adds the element elem as the last element to the end of the queue.

Parameters:
elem - the element to be added to the end of the queue.
See Also:
LinkedList.offer(Object)

dequeue

public T dequeue()
Removes and returns the first element of the queue.

Returns:
The first element of the queue.
See Also:
LinkedList.poll()

front

public T front()
Retrieves (without removing) the first element of the queue.

Returns:
The first element of the queue.
See Also:
LinkedList.peek()

tail

public T tail()
Retrieves (without removing) the last element of the queue.

Returns:
The last element of the queue.
See Also:
LinkedList.getLast()

isEmpty

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

Returns:
true if and only if the queue contains no elements; false otherwise.
See Also:
AbstractCollection.isEmpty()

getUpperLeft

public Node getUpperLeft()
Returns the upper left corner of the queue.

Returns:
the upper left corner of the queue.

setName

public void setName(java.lang.String newName)
Description copied from class: Primitive
Sets the name of this Primitive.

Overrides:
setName in class Primitive
Parameters:
newName - the new name for this Primitive.
See Also:
Primitive.setName(java.lang.String)

getInitContent

public java.util.List<T> getInitContent()
Returns the initial content of the queue.

Returns:
The initial content of the queue.

getProperties

public QueueProperties getProperties()
Returns the properties of the queue.

Returns:
The properties of the queue.

getQueue

public java.util.LinkedList<T> getQueue()
Returns the internal queue as java.util.LinkedList.

Returns:
The internal queue.