static void Main() { ResizableStack<string> stack = new ResizableStack<string>(); stack.Push("Fred"); stack.Push("Flinstone"); Console.WriteLine(stack.Count()); Console.WriteLine(stack.Pop()); Console.WriteLine(stack.Count()); Console.WriteLine(stack.Peek()); Console.WriteLine(stack.Contains("Fred")); Console.WriteLine(stack.Count()); stack.Push("Wilma"); Console.WriteLine(stack.Count()); stack.Push("Barni"); Console.WriteLine(stack.Count()); stack.Clear(); Console.WriteLine(stack.Count()); }
public static void Main() { ResizableStack<int> stack = new ResizableStack<int>(); stack.Puch(5); Console.WriteLine("count: " + stack.Count); Console.WriteLine("capacity: " + stack.Capacity); stack.Puch(5); Console.WriteLine("count: " + stack.Count); Console.WriteLine("capacity: " + stack.Capacity); stack.Puch(5); Console.WriteLine("count: " + stack.Count); Console.WriteLine("capacity: " + stack.Capacity); stack.Puch(5); Console.WriteLine("count: " + stack.Count); Console.WriteLine("capacity: " + stack.Capacity); stack.Puch(5); Console.WriteLine("count: " + stack.Count); Console.WriteLine("capacity: " + stack.Capacity); stack.Puch(5); Console.WriteLine("count: " + stack.Count); Console.WriteLine("capacity: " + stack.Capacity); stack.Puch(2); Console.WriteLine("count: " + stack.Count); Console.WriteLine("capacity: " + stack.Capacity); Console.WriteLine("Peeked: " + stack.Peek()); Console.WriteLine("count: " + stack.Count); Console.WriteLine("Poped: " + stack.Pop()); Console.WriteLine("count: " + stack.Count); Console.WriteLine("Poped: " + stack.Pop()); Console.WriteLine("count: " + stack.Count); Console.WriteLine("Poped: " + stack.Pop()); Console.WriteLine("count: " + stack.Count); }
/* 12. Implement the ADT stack as auto-resizable array. Resize the capacity on demand (when no space is available to add / insert a new element).*/ /// <summary> /// Mains this instance. /// </summary> public static void Main() { ResizableStack<int> testStack = new ResizableStack<int>(); testStack.Push(1); testStack.Push(2); testStack.Push(3); testStack.Pop(); Console.WriteLine(testStack.Peek()); }