public void GivenFullVebTreeWhenRemoveNumberThenFindCantFindIt() { var tree = new VanEmdeBoasTree8(); for (ushort i = 0; i <= byte.MaxValue; i++) { tree.Add((byte)i); } for (ushort i = 0; i <= byte.MaxValue; i++) { tree.Remove((byte)i); Assert.False(tree.Find((byte)i)); } for (ushort i = 0; i <= byte.MaxValue; i++) { tree.Add((byte)i); } for (ushort i = 0; i <= byte.MaxValue; i++) { var toRemove = (byte)(byte.MaxValue - i); tree.Remove(toRemove); Assert.False(tree.Find(toRemove)); } }
public void GivenRandomFilledTreeWhenRemoveThenMatchesArrayState() { for (int randIter = 0; randIter < 1000; randIter++) { var tree = new VanEmdeBoasTree8(); var rand = new Random(); var arr = new bool[1 << 8]; for (int i = 0; i <= byte.MaxValue; i++) { var elem = (byte)rand.Next(1 << 8); arr[elem] = true; tree.Add(elem); } for (int i = 0; i <= byte.MaxValue; i++) { var elem = (byte)rand.Next(1 << 8); Assert.Equal(arr[elem], tree.Remove(elem)); arr[elem] = false; } } }