public void AcceptVisitorExample() { var heap = new Heap<string>(HeapType.Minimum) {"cat", "dog", "canary"}; // There should be 3 items in the heap. Assert.AreEqual(3, heap.Count); // Create a visitor that will simply count the items in the heap. var visitor = new CountingVisitor<string>(); // Make heap call IVisitor<T>.Visit on all items contained. heap.AcceptVisitor(visitor); // The counting visitor would have visited 3 items. Assert.AreEqual(3, visitor.Count); }
public void AcceptVisitorExample() { var heap = new Heap <string>(HeapType.Minimum) { "cat", "dog", "canary" }; // There should be 3 items in the heap. Assert.AreEqual(3, heap.Count); // Create a visitor that will simply count the items in the heap. var visitor = new CountingVisitor <string>(); // Make heap call IVisitor<T>.Visit on all items contained. heap.AcceptVisitor(visitor); // The counting visitor would have visited 3 items. Assert.AreEqual(3, visitor.Count); }