public virtual void Test1() { int degree = 3; NeoDatis.Btree.IBTreeMultipleValuesPerKey tree = new NeoDatis.Btree.Impl.Multiplevalue.InMemoryBTreeMultipleValuesPerKey ("test1", degree); tree.Insert(1, "Value 1"); tree.Insert(20, "Value 20"); tree.Insert(25, "Value 25"); tree.Insert(29, "Value 29"); tree.Insert(21, "Value 21"); AssertEquals(5, tree.GetRoot().GetNbKeys()); AssertEquals(0, tree.GetRoot().GetNbChildren()); AssertEquals(21, tree.GetRoot().GetMedian().GetKey()); AssertEquals("[Value 21]", tree.GetRoot().GetMedian().GetValue().ToString()); AssertEquals(0, tree.GetRoot().GetNbChildren()); // println(tree.getRoot()); tree.Insert(45, "Value 45"); AssertEquals(2, tree.GetRoot().GetNbChildren()); AssertEquals(1, tree.GetRoot().GetNbKeys()); AssertEquals(21, tree.GetRoot().GetKeyAt(0)); AssertEquals("[Value 21]", tree.GetRoot().GetValueAsObjectAt(0).ToString()); // println(tree.getRoot()); System.Collections.IList o = tree.Search(20); AssertEquals("Value 20", o[0]); o = tree.Search(29); AssertEquals("Value 29", o[0]); o = tree.Search(45); AssertEquals("Value 45", o[0]); }
public virtual void Test4() { int degree = 3; NeoDatis.Btree.IBTreeMultipleValuesPerKey tree1 = new NeoDatis.Btree.Impl.Multiplevalue.InMemoryBTreeMultipleValuesPerKey ("1", degree); tree1.Insert(1, "A"); // tree.insert(new Integer(2),"B"); tree1.Insert(3, "C"); tree1.Insert(4, "D"); tree1.Insert(5, "E"); NeoDatis.Btree.IBTreeMultipleValuesPerKey tree2 = new NeoDatis.Btree.Impl.Multiplevalue.InMemoryBTreeMultipleValuesPerKey ("2", degree); tree2.Insert(10, "J"); tree2.Insert(11, "K"); NeoDatis.Btree.IBTreeMultipleValuesPerKey tree3 = new NeoDatis.Btree.Impl.Multiplevalue.InMemoryBTreeMultipleValuesPerKey ("3", degree); tree3.Insert(14, "N"); tree3.Insert(15, "O"); NeoDatis.Btree.IBTreeMultipleValuesPerKey tree4 = new NeoDatis.Btree.Impl.Multiplevalue.InMemoryBTreeMultipleValuesPerKey ("4", degree); tree4.Insert(18, "R"); tree4.Insert(19, "S"); tree4.Insert(20, "T"); tree4.Insert(21, "U"); tree4.Insert(22, "V"); NeoDatis.Btree.IBTreeMultipleValuesPerKey tree5 = new NeoDatis.Btree.Impl.Multiplevalue.InMemoryBTreeMultipleValuesPerKey ("5", degree); tree5.Insert(25, "Y"); tree5.Insert(26, "Z"); NeoDatis.Btree.IBTreeMultipleValuesPerKey tree6 = new NeoDatis.Btree.Impl.Multiplevalue.InMemoryBTreeMultipleValuesPerKey ("6", degree); tree6.Insert(7, "G"); tree6.Insert(13, "M"); tree6.Insert(16, "P"); tree6.Insert(24, "X"); tree6.GetRoot().SetChildAt(tree1.GetRoot(), 0); tree6.GetRoot().SetChildAt(tree2.GetRoot(), 1); tree6.GetRoot().SetChildAt(tree3.GetRoot(), 2); tree6.GetRoot().SetChildAt(tree4.GetRoot(), 3); tree6.GetRoot().SetChildAt(tree5.GetRoot(), 4); tree6.GetRoot().SetNbChildren(5); // println("Test 4"); tree6.Insert(2, "B"); // println(tree6.getRoot().getChild(0).keysToString(true)); AssertEquals("[B]", tree6.GetRoot().GetChildAt(0, true).GetValueAsObjectAt(1).ToString ()); tree6.Insert(17, "Q"); // println(tree6.getRoot().keysToString(true)); AssertEquals(5, tree6.GetRoot().GetNbKeys()); // println(tree6.getRoot().getChild(3).keysToString(true)); AssertEquals("[Q]", tree6.GetRoot().GetChildAt(3, true).GetValueAsObjectAt(0).ToString ()); AssertEquals("[R]", tree6.GetRoot().GetChildAt(3, true).GetValueAsObjectAt(1).ToString ()); AssertEquals("[S]", tree6.GetRoot().GetChildAt(3, true).GetValueAsObjectAt(2).ToString ()); // println(tree6.getRoot().getChild(4).keysToString(true)); AssertEquals("[U]", tree6.GetRoot().GetChildAt(4, true).GetValueAsObjectAt(0).ToString ()); AssertEquals("[V]", tree6.GetRoot().GetChildAt(4, true).GetValueAsObjectAt(1).ToString ()); tree6.Insert(12, "L"); // println(tree6.getRoot().keysToString(true)); AssertEquals(1, tree6.GetRoot().GetNbKeys()); AssertEquals(2, tree6.GetRoot().GetChildAt(0, true).GetNbKeys()); // println(tree6.getRoot().getChild(0).keysToString(true)); AssertEquals("[G]", tree6.GetRoot().GetChildAt(0, true).GetValueAsObjectAt(0).ToString ()); AssertEquals("[M]", tree6.GetRoot().GetChildAt(0, true).GetValueAsObjectAt(1).ToString ()); // println(tree6.getRoot().getChild(0).getChild(1).keysToString(true)); AssertEquals("[J]", tree6.GetRoot().GetChildAt(0, true).GetChildAt(1, true).GetValueAsObjectAt (0).ToString()); AssertEquals("[K]", tree6.GetRoot().GetChildAt(0, true).GetChildAt(1, true).GetValueAsObjectAt (1).ToString()); AssertEquals("[L]", tree6.GetRoot().GetChildAt(0, true).GetChildAt(1, true).GetValueAsObjectAt (2).ToString()); tree6.Insert(6, "F"); // println(tree6.getRoot().keysToString(true)); AssertEquals(1, tree6.GetRoot().GetNbKeys()); AssertEquals(3, tree6.GetRoot().GetChildAt(0, true).GetNbKeys()); AssertEquals(2, tree6.GetRoot().GetChildAt(0, true).GetChildAt(0, true).GetNbKeys ()); // println(tree6.getRoot().getChild(0).getChild(0).keysToString(true)); AssertEquals("[A]", tree6.GetRoot().GetChildAt(0, true).GetChildAt(0, true).GetValueAsObjectAt (0).ToString()); AssertEquals("[B]", tree6.GetRoot().GetChildAt(0, true).GetChildAt(0, true).GetValueAsObjectAt (1).ToString()); // println(tree6.getRoot().getChild(1).getChild(2).keysToString(true)); AssertEquals("[Z]", tree6.GetRoot().GetChildAt(1, true).GetChildAt(2, true).GetValueAsObjectAt (1).ToString()); }
public virtual void Test1() { int degree = 3; NeoDatis.Btree.IBTreeMultipleValuesPerKey tree = new NeoDatis.Btree.Impl.Multiplevalue.InMemoryBTreeMultipleValuesPerKey ("test1", degree); tree.Insert(1, "Value 1"); tree.Insert(20, "Value 20"); tree.Insert(25, "Value 25"); tree.Insert(29, "Value 29"); tree.Insert(21, "Value 21"); AssertEquals(5, tree.GetRoot().GetNbKeys()); AssertEquals(0, tree.GetRoot().GetNbChildren()); AssertEquals(21, tree.GetRoot().GetMedian().GetKey()); AssertEquals("[Value 21]", tree.GetRoot().GetMedian().GetValue().ToString()); AssertEquals(0, tree.GetRoot().GetNbChildren()); // println(tree.getRoot()); tree.Insert(45, "Value 45"); AssertEquals(2, tree.GetRoot().GetNbChildren()); AssertEquals(1, tree.GetRoot().GetNbKeys()); AssertEquals(21, tree.GetRoot().GetKeyAt(0)); AssertEquals("[Value 21]", tree.GetRoot().GetValueAsObjectAt(0).ToString()); // println(tree.getRoot()); System.Collections.IList o = tree.Search(20); AssertEquals("Value 20", o[0]); o = tree.Search(29); AssertEquals("Value 29", o[0]); o = tree.Search(45); AssertEquals("Value 45", o[0]); }
public virtual void Test4() { int degree = 3; NeoDatis.Btree.IBTreeMultipleValuesPerKey tree1 = new NeoDatis.Btree.Impl.Multiplevalue.InMemoryBTreeMultipleValuesPerKey ("1", degree); tree1.Insert(1, "A"); // tree.insert(new Integer(2),"B"); tree1.Insert(3, "C"); tree1.Insert(4, "D"); tree1.Insert(5, "E"); NeoDatis.Btree.IBTreeMultipleValuesPerKey tree2 = new NeoDatis.Btree.Impl.Multiplevalue.InMemoryBTreeMultipleValuesPerKey ("2", degree); tree2.Insert(10, "J"); tree2.Insert(11, "K"); NeoDatis.Btree.IBTreeMultipleValuesPerKey tree3 = new NeoDatis.Btree.Impl.Multiplevalue.InMemoryBTreeMultipleValuesPerKey ("3", degree); tree3.Insert(14, "N"); tree3.Insert(15, "O"); NeoDatis.Btree.IBTreeMultipleValuesPerKey tree4 = new NeoDatis.Btree.Impl.Multiplevalue.InMemoryBTreeMultipleValuesPerKey ("4", degree); tree4.Insert(18, "R"); tree4.Insert(19, "S"); tree4.Insert(20, "T"); tree4.Insert(21, "U"); tree4.Insert(22, "V"); NeoDatis.Btree.IBTreeMultipleValuesPerKey tree5 = new NeoDatis.Btree.Impl.Multiplevalue.InMemoryBTreeMultipleValuesPerKey ("5", degree); tree5.Insert(25, "Y"); tree5.Insert(26, "Z"); NeoDatis.Btree.IBTreeMultipleValuesPerKey tree6 = new NeoDatis.Btree.Impl.Multiplevalue.InMemoryBTreeMultipleValuesPerKey ("6", degree); tree6.Insert(7, "G"); tree6.Insert(13, "M"); tree6.Insert(16, "P"); tree6.Insert(24, "X"); tree6.GetRoot().SetChildAt(tree1.GetRoot(), 0); tree6.GetRoot().SetChildAt(tree2.GetRoot(), 1); tree6.GetRoot().SetChildAt(tree3.GetRoot(), 2); tree6.GetRoot().SetChildAt(tree4.GetRoot(), 3); tree6.GetRoot().SetChildAt(tree5.GetRoot(), 4); tree6.GetRoot().SetNbChildren(5); // println("Test 4"); tree6.Insert(2, "B"); // println(tree6.getRoot().getChild(0).keysToString(true)); AssertEquals("[B]", tree6.GetRoot().GetChildAt(0, true).GetValueAsObjectAt(1).ToString ()); tree6.Insert(17, "Q"); // println(tree6.getRoot().keysToString(true)); AssertEquals(5, tree6.GetRoot().GetNbKeys()); // println(tree6.getRoot().getChild(3).keysToString(true)); AssertEquals("[Q]", tree6.GetRoot().GetChildAt(3, true).GetValueAsObjectAt(0).ToString ()); AssertEquals("[R]", tree6.GetRoot().GetChildAt(3, true).GetValueAsObjectAt(1).ToString ()); AssertEquals("[S]", tree6.GetRoot().GetChildAt(3, true).GetValueAsObjectAt(2).ToString ()); // println(tree6.getRoot().getChild(4).keysToString(true)); AssertEquals("[U]", tree6.GetRoot().GetChildAt(4, true).GetValueAsObjectAt(0).ToString ()); AssertEquals("[V]", tree6.GetRoot().GetChildAt(4, true).GetValueAsObjectAt(1).ToString ()); tree6.Insert(12, "L"); // println(tree6.getRoot().keysToString(true)); AssertEquals(1, tree6.GetRoot().GetNbKeys()); AssertEquals(2, tree6.GetRoot().GetChildAt(0, true).GetNbKeys()); // println(tree6.getRoot().getChild(0).keysToString(true)); AssertEquals("[G]", tree6.GetRoot().GetChildAt(0, true).GetValueAsObjectAt(0).ToString ()); AssertEquals("[M]", tree6.GetRoot().GetChildAt(0, true).GetValueAsObjectAt(1).ToString ()); // println(tree6.getRoot().getChild(0).getChild(1).keysToString(true)); AssertEquals("[J]", tree6.GetRoot().GetChildAt(0, true).GetChildAt(1, true).GetValueAsObjectAt (0).ToString()); AssertEquals("[K]", tree6.GetRoot().GetChildAt(0, true).GetChildAt(1, true).GetValueAsObjectAt (1).ToString()); AssertEquals("[L]", tree6.GetRoot().GetChildAt(0, true).GetChildAt(1, true).GetValueAsObjectAt (2).ToString()); tree6.Insert(6, "F"); // println(tree6.getRoot().keysToString(true)); AssertEquals(1, tree6.GetRoot().GetNbKeys()); AssertEquals(3, tree6.GetRoot().GetChildAt(0, true).GetNbKeys()); AssertEquals(2, tree6.GetRoot().GetChildAt(0, true).GetChildAt(0, true).GetNbKeys ()); // println(tree6.getRoot().getChild(0).getChild(0).keysToString(true)); AssertEquals("[A]", tree6.GetRoot().GetChildAt(0, true).GetChildAt(0, true).GetValueAsObjectAt (0).ToString()); AssertEquals("[B]", tree6.GetRoot().GetChildAt(0, true).GetChildAt(0, true).GetValueAsObjectAt (1).ToString()); // println(tree6.getRoot().getChild(1).getChild(2).keysToString(true)); AssertEquals("[Z]", tree6.GetRoot().GetChildAt(1, true).GetChildAt(2, true).GetValueAsObjectAt (1).ToString()); }