algoanim.primitives
Class ListBasedStack<T>

java.lang.Object
  extended by algoanim.primitives.Primitive
      extended by algoanim.primitives.VisualStack<T>
          extended by algoanim.primitives.ListBasedStack<T>

public class ListBasedStack<T>
extends VisualStack<T>

Represents a stack which has an usual LIFO-functionality and will be visualized using a linked list.
The stored objects are of the generic data type T, so it is generally possible to use ListBasedStack with any objects.

Author:
Dima Vronskyi

Field Summary
 
Fields inherited from class algoanim.primitives.Primitive
gen
 
Constructor Summary
ListBasedStack(ListBasedStackGenerator<T> lbsg, Node upperLeftCorner, java.util.List<T> content, java.lang.String name, DisplayOptions display, StackProperties sp)
          Instantiates the ListBasedStack and calls the create() method of the associated ListBasedStackGenerator.
 
Method Summary
 void highlightTopCell(Timing delay, Timing duration)
          Highlights the cell which contains the top element of the stack.
 void highlightTopElem(Timing delay, Timing duration)
          Highlights the top element of the stack.
 boolean isEmpty(Timing delay, Timing duration)
          Tests if the stack is empty.
This is the delayed version as specified by delay.
 T pop(Timing delay, Timing duration)
          Removes and returns the element at the top of the stack.
This is the delayed version as specified by delay.
 void push(T elem, Timing delay, Timing duration)
          Pushes the element elem onto the top of the stack.
 T top(Timing delay, Timing duration)
          Retrieves (without removing) the element at the top of the stack.
This is the delayed version as specified by delay.
 void unhighlightTopCell(Timing delay, Timing duration)
          Unhighlights the cell which contains the top element of the stack.
 void unhighlightTopElem(Timing delay, Timing duration)
          Unhighlights the top element of the stack.
 
Methods inherited from class algoanim.primitives.VisualStack
getInitContent, getProperties, getStack, getUpperLeft, isEmpty, pop, push, setName, top
 
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

ListBasedStack

public ListBasedStack(ListBasedStackGenerator<T> lbsg,
                      Node upperLeftCorner,
                      java.util.List<T> content,
                      java.lang.String name,
                      DisplayOptions display,
                      StackProperties sp)
Instantiates the ListBasedStack and calls the create() method of the associated ListBasedStackGenerator.

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

push

public void push(T elem,
                 Timing delay,
                 Timing duration)
Pushes the element elem onto the top of the stack. Unlike the push-method of java.util.Stack it doesn't return the element to be pushed.
This is the delayed version as specified by delay. The duration of this operation may also be specified.

Parameters:
elem - the element to be pushed onto the stack.
delay - [optional] the delay which shall be applied to the operation.
duration - [optional] the duration this action needs.

pop

public T pop(Timing delay,
             Timing duration)
Removes and returns the element at the top of the stack.
This is the delayed version as specified by delay. The duration of this operation may also be specified.

Parameters:
delay - [optional] the delay which shall be applied to the operation.
duration - [optional] the duration this action needs.
Returns:
The element at the top of the stack.
Throws:
java.util.EmptyStackException - - if the stack is empty.

top

public T top(Timing delay,
             Timing duration)
Retrieves (without removing) the element at the top of the stack.
This is the delayed version as specified by delay. The duration of this operation may also be specified.

Parameters:
delay - [optional] the delay which shall be applied to the operation.
duration - [optional] the duration this action needs.
Returns:
The element at the top of the stack.
Throws:
java.util.EmptyStackException - - if the stack is empty.

isEmpty

public boolean isEmpty(Timing delay,
                       Timing duration)
Tests if the stack is empty.
This is the delayed version as specified by delay. The duration of this operation may also be specified.

Parameters:
delay - [optional] the delay which shall be applied to the operation.
duration - [optional] the duration this action needs.
Returns:
true if and only if the stack contains no elements; false otherwise.

highlightTopElem

public void highlightTopElem(Timing delay,
                             Timing duration)
Highlights the top element of the stack. This is the delayed version as specified by delay. The duration of this operation may also be specified.

Parameters:
delay - [optional] the delay which shall be applied to the operation.
duration - [optional] the duration this action needs.

unhighlightTopElem

public void unhighlightTopElem(Timing delay,
                               Timing duration)
Unhighlights the top element of the stack. This is the delayed version as specified by delay. The duration of this operation may also be specified.

Parameters:
delay - [optional] the delay which shall be applied to the operation.
duration - [optional] the duration this action needs.

highlightTopCell

public void highlightTopCell(Timing delay,
                             Timing duration)
Highlights the cell which contains the top element of the stack. This is the delayed version as specified by delay. The duration of this operation may also be specified.

Parameters:
delay - [optional] the delay which shall be applied to the operation.
duration - [optional] the duration this action needs.

unhighlightTopCell

public void unhighlightTopCell(Timing delay,
                               Timing duration)
Unhighlights the cell which contains the top element of the stack. This is the delayed version as specified by delay. The duration of this operation may also be specified.

Parameters:
delay - [optional] the delay which shall be applied to the operation.
duration - [optional] the duration this action needs.