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