private void Stack_Implementation_Of_Linkedlist_Click(object sender, EventArgs e) { StackWithLinkedList list = new StackWithLinkedList(); Console.WriteLine("Checking Is Empty - " + list.IsEmpty()); Console.WriteLine("Push 5 - "); list.Push(5); Console.WriteLine("Push 4 - "); list.Push(4); Console.WriteLine("Push 3 - "); list.Push(3); Console.WriteLine("Pop 3 - " + list.Pop().data); Console.WriteLine("Pop 4 - " + list.Pop().data); Console.WriteLine("Checking Is Empty - " + list.IsEmpty()); Console.WriteLine("Pop 5 - " + list.Pop().data); Console.WriteLine("Checking Is Empty - " + list.IsEmpty()); }
public void Stack_Is_Empty() { var stack = new StackWithLinkedList <int>(); var isEmpty = stack.IsEmpty(); Assert.True(isEmpty); Assert.Equal(0, stack.Length); Assert.Null(stack.Top); Assert.Null(stack.Bottom); }
public void Stack_Is_Not_Empty() { var stack = new StackWithLinkedList <int>(); stack.Push(10); var isEmpty = stack.IsEmpty(); Assert.False(isEmpty); Assert.Equal(1, stack.Length); Assert.NotNull(stack.Top); Assert.NotNull(stack.Bottom); }
public override void Push(int value) { base.Push(value); var sorted = new StackWithLinkedList <int>(); while (!base.IsEmpty()) { int element = base.Pop(); while (!sorted.IsEmpty() && sorted.Peek() > element) { base.Push(sorted.Pop()); } sorted.Push(element); } while (!sorted.IsEmpty()) { base.Push(sorted.Pop()); } }
public void StackWithLinkedList_IsEmpty_should_return_true_when_stack_is_empty() { Assert.AreEqual(true, st.IsEmpty()); }