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