public void InsertTest() { var empty = BootstrappedHeap <string> .Empty; var heap = BootstrappedHeap <string> .Insert("A", empty); Assert.AreEqual("A", BootstrappedHeap <string> .FindMin(heap)); }
public void EmptyTest() { var t = BootstrappedHeap <string> .Empty; Assert.IsTrue(BootstrappedHeap <string> .IsEmpty(t)); var t1 = BootstrappedHeap <string> .Insert("C", t); Assert.IsFalse(BootstrappedHeap <string> .IsEmpty(t1)); }
public void FindMinTest() { var ts1 = "c a b".Split().Aggregate(BootstrappedHeap <string> .Empty, (current, word) => BootstrappedHeap <string> .Insert(word, current)); Assert.AreEqual("a", BootstrappedHeap <string> .FindMin(ts1)); }
public void Merge3Test() { var heap1 = "c a b".Split().Aggregate(BootstrappedHeap <string> .Empty, (current, word) => BootstrappedHeap <string> .Insert(word, current)); var heap2 = "z x y".Split().Aggregate(BootstrappedHeap <string> .Empty, (current, word) => BootstrappedHeap <string> .Insert(word, current)); var heap3 = BootstrappedHeap <string> .Merge(heap1, heap2); Assert.AreEqual("[a: {[b: Empty]: {[c: Empty]: {[x: {[y: Empty]: {[z: Empty]: Empty}}]: Empty}}}]", DumpHeap(heap3)); }
public void Merge2Test() { var heap1 = "c a b".Split().Aggregate(BootstrappedHeap <string> .Empty, (current, word) => BootstrappedHeap <string> .Insert(word, current)); var heap3 = BootstrappedHeap <string> .Merge(heap1, BootstrappedHeap <string> .Empty); Assert.AreSame(heap1, heap3); }