Skip to content

Instantly share code, notes, and snippets.

@lggomez
Last active April 24, 2017 21:06
Show Gist options
  • Select an option

  • Save lggomez/005a166b0296e0e6c79d6bec40d3ad79 to your computer and use it in GitHub Desktop.

Select an option

Save lggomez/005a166b0296e0e6c79d6bec40d3ad79 to your computer and use it in GitHub Desktop.
public class MyStack<T>
{
readonly int m_Size;
readonly T[] m_Items;
int m_StackPointer = 0;
public MyStack(int size)
{
m_Size = size;
m_Items = new T[m_Size];
}
public T Pop()
{
m_StackPointer--;
return m_Items[m_StackPointer];
}
public void Push(T item)
{
m_Items[m_StackPointer] = item;
m_StackPointer++;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment