public void InsertUniqueWithRepeat() { var btree = new BTree <string, string>(_ => _, Comparer <string> .Default); // Seeding the tree foreach (var intValue in Enumerable.Range(0, 65536)) { var strValue = (intValue % 65536).ToString("000000"); var result = btree.InsertUnique(strValue); Assert.That(result, Is.Not.Null); Assert.That(result.Succeeded, Is.True); } foreach (var intValue in Enumerable.Range(0, 65536)) { var strValue = (intValue % 65536).ToString("000000"); var result = btree.InsertUnique(strValue); Assert.That(result.Succeeded, Is.False); Assert.That(result.Cursor, Is.Not.Null); Assert.That(result.Cursor.Key, Is.EqualTo(strValue)); Assert.That(result.Cursor.Value, Is.EqualTo(strValue)); } }
private static BTree <string, string> CreateTree(int numKeys, Random random = null) { if (random == null) { random = new Random(1000); // consistent seed for testing } var btree = new BTree <string, string>(_ => _, Comparer <string> .Default, 3); for (int ii = 0; ii < numKeys; ii++) { var key = ii.ToString("000000"); btree.InsertUnique(key); } return(btree); }