001package jmri.jmrit.logixng;
002
003/**
004 * A table that is a stack
005 * 
006 * @author Daniel Bergqvist 2020
007 */
008public interface Stack {
009    
010    /**
011     * Pushes a value on the top of the stack so the stack grow.
012     * @param value the value to push to the stack
013     */
014    void push(Object value);
015    
016    /**
017     * Pops the topmost value off the top of the stack so the stack shrinks.
018     * @return the value that is on the top of the stack
019     */
020    Object pop();
021    
022    /**
023     * Get the value at an index
024     * @param index the index from bottom of the table
025     * @return value the new value
026     */
027    Object getValueAtIndex(int index);
028    
029    /**
030     * Set the value at an index
031     * @param index the index from bottom of the table
032     * @param value the new value
033     */
034    void setValueAtIndex(int index, Object value);
035    
036    /**
037     * Get the number of items on the stack
038     * @return the number of items
039     */
040    int getCount();
041    
042    /**
043     * Reset the number of items on the stack.
044     * This is used when parameters are put on the stack before a call to a
045     * module and those parameters needs to be removed when the module returns.
046     * The new count must be less than or equal to the current number of items.
047     * @param newCount the new number of items
048     */
049    void setCount(int newCount);
050    
051}