public T Pop() { MyStackElement <T> toReturn = content[position - 1]; position--; return(toReturn.value); }
public MyStackElement <T>[] CopyArray(MyStackElement <T>[] arr) { size = size * 2; MyStackElement <T>[] toReturn = new MyStackElement <T> [size]; for (int i = 0; i < arr.Length; i++) { toReturn[i] = arr[i]; } return(toReturn); }
public void Push(T value) { MyStackElement <T> elementToAdd = new MyStackElement <T>() { value = value }; if (position == content.Length - 1) { content = CopyArray(content); } if (content[0] == null) { content[0] = elementToAdd; content[0].position = 0; position++; } else { content[position] = elementToAdd; position++; } }