public void Populate3() { KukuTable ct = new KukuTable( new KukuTableParameters { TableSize = 1 << 10, StashSize = 0, LocFuncCount = 2, LocFuncSeed = Item.MakeZeroItem(), MaxProbe = 10, EmptyItem = Item.MakeRandomItem() } ); for (uint i = 0; i < ct.TableSize; i++) { Assert.IsTrue(ct.IsEmpty(i)); } Assert.IsTrue(ct.Insert(Item.MakeItem(0, 0))); Assert.IsTrue(ct.Insert(Item.MakeItem(1, 0))); Assert.IsTrue(ct.Insert(Item.MakeItem(0, 1))); Assert.IsTrue(ct.Insert(Item.MakeItem(1, 1))); Assert.IsTrue(ct.Insert(Item.MakeItem(2, 2))); Utilities.AssertThrows <ArgumentException>(() => ct.Insert(ct.EmptyItem)); // Fails Assert.IsFalse(ct.Insert(Item.MakeItem(2, 2))); int nonEmpties = 0; for (uint i = 0; i < ct.TableSize; i++) { nonEmpties += ct.IsEmpty(i) ? 0 : 1; } Assert.AreEqual(5, nonEmpties); Assert.IsTrue(ct.Query(Item.MakeItem(0, 0)).Found); Assert.IsTrue(ct.Query(Item.MakeItem(1, 0)).Found); Assert.IsTrue(ct.Query(Item.MakeItem(0, 1)).Found); Assert.IsTrue(ct.Query(Item.MakeItem(1, 1)).Found); Assert.IsTrue(ct.Query(Item.MakeItem(2, 2)).Found); Assert.IsFalse(ct.Query(Item.MakeItem(3, 3)).Found); }
public void Populate1() { KukuTable ct = new KukuTable( new KukuTableParameters { TableSize = 1, StashSize = 0, LocFuncCount = 2, LocFuncSeed = Item.MakeZeroItem(), MaxProbe = 10, EmptyItem = Item.MakeZeroItem() } ); Assert.IsTrue(ct.IsEmptyItem(ct[0])); Assert.IsTrue(ct.Insert(Item.MakeItem(1, 0))); Assert.IsFalse(ct.Insert(Item.MakeItem(0, 1))); Utilities.AssertThrows <ArgumentException>(() => ct.Insert(ct.EmptyItem)); Utilities.AssertThrows <ArgumentException>(() => ct.Insert(Item.MakeZeroItem())); Assert.IsFalse(ct.IsEmpty(0)); }