public void DeleteString(StringNode StringToDelete) { StringNode nodeWalker = head; //If deleting the only pellet in the list if (head == tail) { head = null; tail = null; } else { //If deleting first pellet in list when there are more than one in list if (StringToDelete == head && StringToDelete.Next != null) { head = StringToDelete.Next; } else { while (nodeWalker.Next != StringToDelete) { nodeWalker = nodeWalker.Next; } nodeWalker.Next = StringToDelete.Next; //If deleting last pellet in list if (StringToDelete.Next == null) { tail = nodeWalker; } } } }
public void AddString(StringNode newString) { if (head == null) { head = newString; tail = newString; } else { tail.Next = newString; tail = newString; } }
public void IsEmptyTestOnPreviouslyPopulatedStackNowEmpty() { Stack testStack = new Stack(); StringNode testString1 = new StringNode(); StringNode testString2 = new StringNode(); testString1.Value = "Test String 1"; testString2.Value = "Test String 2"; bool expected = true; testStack.Push(testString1); testStack.Push(testString2); testStack.Pop(); testStack.Pop(); bool actual = testStack.IsEmpty(); Assert.AreEqual(expected, actual); }
public void CountTestOnPreviouslyPoplulatedStack() { Stack testStack = new Stack(); StringNode testString1 = new StringNode(); StringNode testString2 = new StringNode(); testString1.Value = "Test String 1"; testString2.Value = "Test String 2"; int expected = 0; testStack.Push(testString1); testStack.Push(testString2); testStack.Pop(); testStack.Pop(); int actual = testStack.Count(); Assert.AreEqual(expected, actual); }
public LinkedList() { head = null; tail = null; }
public void PeekTestOnPreviouslyPoplulatedStack() { Stack testStack = new Stack(); StringNode testString1 = new StringNode(); StringNode testString2 = new StringNode(); testString1.Value = "Test String 1"; testString2.Value = "Test String 2"; testStack.Push(testString1); testStack.Push(testString2); testStack.Pop(); testStack.Pop(); string actual = testStack.Peek(); }
public void PeekTestOnPopulatedStack() { Stack testStack = new Stack(); StringNode testString1 = new StringNode(); StringNode testString2 = new StringNode(); StringNode testString3 = new StringNode(); testString1.Value = "Test String 1"; testString2.Value = "Test String 2"; testString3.Value = "Test String 3"; bool expected = true; testStack.Push(testString1); testStack.Push(testString2); testStack.Push(testString3); String testPeek = testStack.Peek(); String testStringStillExists = testStack.Peek(); bool actual = (testPeek == testString3.Value && testStringStillExists == testString3.Value); Assert.AreEqual(expected, actual); }
public void IsEmptyTestOnStackWithItems() { Stack testStack = new Stack(); StringNode testString1 = new StringNode(); StringNode testString2 = new StringNode(); testString1.Value = "Test String 1"; testString2.Value = "Test String 2"; bool expected = false; testStack.Push(testString1); testStack.Push(testString2); bool actual = testStack.IsEmpty(); Assert.AreEqual(expected, actual); }
public void Push(StringNode newString) { stackList.AddString(newString); }