Class DefaultStack
- java.lang.Object
-
- jmri.jmrit.logixng.implementation.DefaultStack
-
- All Implemented Interfaces:
Stack
public class DefaultStack extends java.lang.Object implements Stack
The default implementation of a NamedTable
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface jmri.jmrit.logixng.Stack
Stack.ValueAndType
-
-
Field Summary
Fields Modifier and Type Field Description (package private) int
_count
(package private) int
_size
(package private) static int
GROW_SIZE
(package private) static int
INITIAL_SIZE
-
Constructor Summary
Constructors Constructor Description DefaultStack()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getCount()
Get the number of items on the stackStack.ValueAndType
getValueAndTypeAtIndex(int index)
Get the value and type at an indexjava.lang.Object
getValueAtIndex(int index)
Get the value at an indexjava.lang.Object
pop()
Pops the topmost value off the top of the stack so the stack shrinks.void
push(Stack.ValueAndType valueAndType)
Pushes a value on the top of the stack so the stack grow.void
setCount(int newCount)
Reset the number of items on the stack.void
setValueAndTypeAtIndex(int index, Stack.ValueAndType valueAndType)
Set the value at an indexvoid
setValueAtIndex(int index, java.lang.Object value)
Set the value at an index
-
-
-
Field Detail
-
INITIAL_SIZE
static final int INITIAL_SIZE
- See Also:
- Constant Field Values
-
GROW_SIZE
static final int GROW_SIZE
- See Also:
- Constant Field Values
-
_size
int _size
-
_count
int _count
-
-
Constructor Detail
-
DefaultStack
public DefaultStack()
-
-
Method Detail
-
push
public void push(Stack.ValueAndType valueAndType)
Pushes a value on the top of the stack so the stack grow.
-
pop
public java.lang.Object pop()
Pops the topmost value off the top of the stack so the stack shrinks.
-
getValueAtIndex
public java.lang.Object getValueAtIndex(int index)
Get the value at an index- Specified by:
getValueAtIndex
in interfaceStack
- Parameters:
index
- the index from bottom of the table- Returns:
- value the new value
-
setValueAtIndex
public void setValueAtIndex(int index, java.lang.Object value)
Set the value at an index- Specified by:
setValueAtIndex
in interfaceStack
- Parameters:
index
- the index from bottom of the tablevalue
- the new value
-
getValueAndTypeAtIndex
public Stack.ValueAndType getValueAndTypeAtIndex(int index)
Get the value and type at an index- Specified by:
getValueAndTypeAtIndex
in interfaceStack
- Parameters:
index
- the index from bottom of the table- Returns:
- value and type the new value
-
setValueAndTypeAtIndex
public void setValueAndTypeAtIndex(int index, Stack.ValueAndType valueAndType)
Set the value at an index- Specified by:
setValueAndTypeAtIndex
in interfaceStack
- Parameters:
index
- the index from bottom of the tablevalueAndType
- the new value and type
-
getCount
public int getCount()
Get the number of items on the stack
-
setCount
public void setCount(int newCount)
Reset the number of items on the stack. This is used when parameters are put on the stack before a call to a module and those parameters needs to be removed when the module returns. The new count must be less than or equal to the current number of items.
-
-