public void GivenEmptyVebTreeWhenFindThenAlwaysReturnFalse() { var tree = new VanEmdeBoasTree32(); var rand = new Random(); for (uint i = 0; i < 1 << 8; i++) { var elem = (uint)(rand.Next(1 << 30)) << 2 | (uint)(rand.Next(1 << 2)); Assert.False(tree.Find(elem)); } }
public void GivenFullVebTreeWhenRemoveNumberThenFindCantFindIt() { var tree = new VanEmdeBoasTree32(); for (uint i = 0; i < 1 << 17; i++) { tree.Add(i); } for (uint i = 0; i < 1 << 17; i++) { tree.Remove(i); Assert.False(tree.Find(i)); } for (uint i = 0; i < 1 << 17; i++) { tree.Add(i); } for (uint i = 0; i < 1 << 17; i++) { var toRemove = (1 << 17) - 1 - i; tree.Remove(toRemove); Assert.False(tree.Find(toRemove)); } }
public void GivenVebTreePopulatedWithOddNumbersWhenFindReturnsCorrectValue() { var tree = new VanEmdeBoasTree32(); for (uint i = 0; i < 1 << 8; i++) { if (i % 2 == 1) { tree.Add(i); } } for (uint i = 0; i < 1 << 8; i++) { Assert.Equal(i % 2 == 1, tree.Find(i)); } }
public void GivenPopulatedVebTreeWhenFindThenAlwaysReturnTrue() { var tree = new VanEmdeBoasTree32(); var rand = new Random(); var set = new HashSet <uint>(); for (int i = 0; i < 1 << 10; i++) { var elem = (uint)(rand.Next(1 << 30)) << 2 | (uint)(rand.Next(1 << 2)); set.Add(elem); tree.Add(elem); } foreach (var elem in set) { Assert.True(tree.Find(elem)); } }