public void BreadthFirstSearch(Action <K, T> action) { var queue = new LinkedListQueue <Node <K, T> >().Enqueue(root); while (!queue.IsEmprty()) { var currentNode = queue.Dequeue(); action.Invoke(currentNode.Key, currentNode.Value); if (!queue.Contains(currentNode.Left) && currentNode.Left == null) { queue.Enqueue(currentNode.Left); } if (!queue.Contains(currentNode.Right) && currentNode.Right == null) { queue.Enqueue(currentNode.Right); } } }
public void TestLinkedListQueueContains() { LinkedListQueue <int> queue = new LinkedListQueue <int>(); queue.Enqueue(1); queue.Enqueue(2); queue.Enqueue(3); queue.Enqueue(4); queue.Enqueue(5); Assert.IsTrue(queue.Contains(5)); }
public void Contains_ShouldBeTrue() { bool contains = queue.Contains(oneValue); Assert.True(contains); }
public void Contains_ShouldBeTrue() { bool contains = queue.Contains(unsortedArray[10]); Assert.True(contains); }
public void TestLinkedListQueueContains() { LinkedListQueue<int> queue = new LinkedListQueue<int>(); queue.Enqueue(1); queue.Enqueue(2); queue.Enqueue(3); queue.Enqueue(4); queue.Enqueue(5); Assert.IsTrue(queue.Contains(5)); }