public void CheckIsEmptyMethodStack() { Assert.IsTrue(stack.IsEmpty()); stack.Push(666); Assert.IsFalse(stack.IsEmpty()); stack.Pop(); Assert.IsTrue(stack.IsEmpty()); }
public static int[] CalculateSpan(int[] Input) { int len = Input.Length; int[] Span = new int[len]; //Span[0] = 0; IStack stk = new StackArray(len); //stk.Push(0); for (int i = 0; i < len; i++) { if (i == 0) { Span[0] = 0; stk.Push(0); } else { if (Input[i] < Input[i - 1]) { Span[i] = 1; stk.Push(i); } else { while (!stk.IsEmpty() && Input[stk.Top()] < Input[i]) { stk.Pop(); } if (stk.IsEmpty()) { Span[i] = 0; stk.Push(i); } else { Span[i] = i - stk.Top(); stk.Push(i); } } } } return(Span); }
public void IsEmpty_EmptyStackArrayShouldReturnTrue() { // Arrange StackArray <int> sut = new StackArray <int>(); bool expected = true; // Act bool actual = sut.IsEmpty(); // Assert Assert.Equal(expected, actual); }
public override int Pop() { while (!IsEmpty()) { _stackArray.Push(base.Pop()); } int ret = _stackArray.Pop(); while (!_stackArray.IsEmpty()) { Push(_stackArray.Pop()); } return(ret); }
public void PushArrayStackTest() { stack.Push(1.4); Assert.IsFalse(stack.IsEmpty()); }