public void NonIComparable() { var splayTree = new SplayTree <NonComparableTClass, string> { { new NonComparableTClass(4), "4" }, { new NonComparableTClass(6), "6" }, { new NonComparableTClass(2), "2" }, { new NonComparableTClass(5), "5" }, { new NonComparableTClass(19), "19" }, { new NonComparableTClass(1), "1" } }; var newTree = SerializeUtil.BinarySerializeDeserialize(splayTree); Assert.AreNotSame(splayTree, newTree); Assert.AreEqual(splayTree.Count, newTree.Count); var splayTreeEnumerator = splayTree.GetEnumerator(); var newTreeEnumerator = newTree.GetEnumerator(); while (splayTreeEnumerator.MoveNext()) { Assert.IsTrue(newTreeEnumerator.MoveNext()); Assert.AreEqual(splayTreeEnumerator.Current.Key.Number, newTreeEnumerator.Current.Key.Number); Assert.AreEqual(splayTreeEnumerator.Current.Value, newTreeEnumerator.Current.Value); //TODO: Need a way of accessing an item without splaying //Assert.AreEqual(newTree.ContainsKey(splayTreeEnumerator.Current.Key)); //Assert.AreEqual(newTree[treeEnumerator.Current.Key], splayTreeEnumerator.Current.Value); } Assert.IsFalse(newTreeEnumerator.MoveNext()); }
public void NonIComparable() { var splayTree = new SplayTree<NonComparableTClass, string> { {new NonComparableTClass(4), "4"}, {new NonComparableTClass(6), "6"}, {new NonComparableTClass(2), "2"}, {new NonComparableTClass(5), "5"}, {new NonComparableTClass(19), "19"}, {new NonComparableTClass(1), "1"} }; var newTree = SerializeUtil.BinarySerializeDeserialize(splayTree); Assert.AreNotSame(splayTree, newTree); Assert.AreEqual(splayTree.Count, newTree.Count); var splayTreeEnumerator = splayTree.GetEnumerator(); var newTreeEnumerator = newTree.GetEnumerator(); while (splayTreeEnumerator.MoveNext()) { Assert.IsTrue(newTreeEnumerator.MoveNext()); Assert.AreEqual(splayTreeEnumerator.Current.Key.Number, newTreeEnumerator.Current.Key.Number); Assert.AreEqual(splayTreeEnumerator.Current.Value, newTreeEnumerator.Current.Value); //TODO: Need a way of accessing an item without splaying //Assert.AreEqual(newTree.ContainsKey(splayTreeEnumerator.Current.Key)); //Assert.AreEqual(newTree[treeEnumerator.Current.Key], splayTreeEnumerator.Current.Value); } Assert.IsFalse(newTreeEnumerator.MoveNext()); }
public IEnumerator <T> GetEnumerator() { return(data.GetEnumerator()); }