fr.umlv.tatoo.runtime.util
Class IntArrayList

java.lang.Object
  extended by fr.umlv.tatoo.runtime.util.IntArrayList
All Implemented Interfaces:
ReadOnlyIntStack

public class IntArrayList
extends Object
implements ReadOnlyIntStack

A specific array list of integer that globally works as a stack to store parser state.

Author:
Julien

Constructor Summary
IntArrayList()
          Creates the list with 10 as initial capacity.
IntArrayList(int initialCapacity)
          Creates the list with an initial capacity.
 
Method Summary
 void add(int value)
          Adds a value on top of the list.
 void clear()
          Clear the whole list.
 IntArrayList duplicate()
          Duplicates the current stack.
 int get(int index)
          Returns the state number at the given position.
 boolean isEmpty()
          Returns true is the number of states in the stack is zero.
 int last()
          Returns last inserted (i.e. the current) state.
 int removeLast()
          Removes the last value on top of the stack and returns it.
 void removeLast(int number)
          Removes the last values on top of the stack.
 void set(int index, int value)
          Changes the value at index index by a new one.
 int size()
          Returns the number of states in the stack.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IntArrayList

public IntArrayList(int initialCapacity)
Creates the list with an initial capacity.

Parameters:
initialCapacity - the initiali capacity

IntArrayList

public IntArrayList()
Creates the list with 10 as initial capacity.

See Also:
IntArrayList(int)
Method Detail

duplicate

public IntArrayList duplicate()
Description copied from interface: ReadOnlyIntStack
Duplicates the current stack.

Specified by:
duplicate in interface ReadOnlyIntStack
Returns:
a new stack with the same states that the current one.

add

public void add(int value)
Adds a value on top of the list.

Parameters:
value - the value to add.

removeLast

public void removeLast(int number)
Removes the last values on top of the stack.

Parameters:
number - the number of values to remove.

removeLast

public int removeLast()
Removes the last value on top of the stack and returns it.

Returns:
the value on top of the stack.
See Also:
removeLast(int)

last

public int last()
Description copied from interface: ReadOnlyIntStack
Returns last inserted (i.e. the current) state.

Specified by:
last in interface ReadOnlyIntStack
Returns:
the current state.

clear

public void clear()
Clear the whole list.


get

public int get(int index)
Description copied from interface: ReadOnlyIntStack
Returns the state number at the given position.

Specified by:
get in interface ReadOnlyIntStack
Parameters:
index - the position.
Returns:
the state number.

set

public void set(int index,
                int value)
Changes the value at index index by a new one. This call assume that the value at index index if already allowed so it doesn't ensure a capacity, you can use add(int) instead.

Parameters:
index -
value -

size

public int size()
Description copied from interface: ReadOnlyIntStack
Returns the number of states in the stack.

Specified by:
size in interface ReadOnlyIntStack
Returns:
the number of states in the stack.

isEmpty

public boolean isEmpty()
Description copied from interface: ReadOnlyIntStack
Returns true is the number of states in the stack is zero.

Specified by:
isEmpty in interface ReadOnlyIntStack
Returns:
true if the stack is empty, false otherwise.

toString

public String toString()
Overrides:
toString in class Object