// @topic T060530 Stack of integers
// @brief Stack class implementation

#include "Stack.h"

Stack::Stack()
{
    stack_memory = new int[ DEFAULT_CAPACITY ];
    capacity = DEFAULT_CAPACITY;
    top_pos = 0;
}

Stack::Stack( int initial_capacity )
{
    stack_memory = new int[ initial_capacity ];
    capacity = initial_capacity;
    top_pos = 0;
}

void Stack::push( int value )
{
    stack_memory[ top_pos ] = value;
    ++top_pos;
}

void Stack::pop()
{
    --top_pos;
}

int Stack::top() const
{
    return stack_memory[ top_pos ];
}

int& Stack::top()
{
    return stack_memory[ top_pos ];
}

int Stack::size() const
{
    return top_pos;
}