org.xmloperator.lambda.net.model
Interface WalkStack


public interface WalkStack

Stack of Walks.


Method Summary
 Walk getFromTop(int index)
          Return the Walk at a given top relative index in the stack.
 int getSize()
          Return the size of this stack.
 void insertFromTop(int index, Walk walk)
          Inserts a Walk in this stack at a top relative index.
 boolean isEmpty()
          Returns true if this stack is empty.
 Walk pop()
          Pops a Walk from this stack.
 void push(Walk walk)
          Pushes a Walk on this stack.
 Walk removeFromTop(int index)
          Removes and returns the Walk at a given top relative index in the stack.
 void returnToFactory()
          Return this stack to the Factory.
 Walk top()
          Returns the Walk at the top of this stack or null if it is empty.
 

Method Detail

returnToFactory

public void returnToFactory()
Return this stack to the Factory.

Post-condition: this is no more usable.


getSize

public int getSize()
Return the size of this stack.

Returns:
the size of this stack.

isEmpty

public boolean isEmpty()
Returns true if this stack is empty.

Returns:
true if this stack is empty.

push

public void push(Walk walk)
Pushes a Walk on this stack.

Parameters:
walk - a Walk.
Throws:
java.lang.IllegalArgumentException - if the given Walk is null.

pop

public Walk pop()
Pops a Walk from this stack.

Returns:
the poped Walk.
Throws:
java.lang.IllegalStateException - if the stack is empty.

top

public Walk top()
Returns the Walk at the top of this stack or null if it is empty.

Returns:
the Walk at the top of this stack or null if it is empty.

getFromTop

public Walk getFromTop(int index)
Return the Walk at a given top relative index in the stack. getFromTop(0) is equivalent to top().

Parameters:
index - an index in the stack, between 0 and size - 1.
Returns:
the Walk at the index position.
Throws:
java.lang.IndexOutOfBoundsException - if index < 0 or index >= size.

insertFromTop

public void insertFromTop(int index,
                          Walk walk)
Inserts a Walk in this stack at a top relative index. insertFromTop(0, w) is equivalent to push(w).

Parameters:
index - a top relative index.
walk - a Walk.
Throws:
java.lang.IndexOutOfBoundsException - if index < 0 or index >= size.

removeFromTop

public Walk removeFromTop(int index)
Removes and returns the Walk at a given top relative index in the stack.

Parameters:
index - a top relative index.
Returns:
the removed Walk.
Throws:
java.lang.IndexOutOfBoundsException - if index < 0 or index >= size.