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 GivenRandomFilledTreeWhenRemoveThenMatchesArrayState() { var tree = new VanEmdeBoasTree32(); var rand = new Random(); var arr = new bool[1 << 17]; for (int i = 0; i < 1 << 7; i++) { var elem = (uint)rand.Next(1 << 17); arr[elem] = true; tree.Add(elem); } for (int i = 0; i < 1 << 7; i++) { var elem = (uint)rand.Next(1 << 17); Assert.Equal(arr[elem], tree.Remove(elem)); arr[elem] = false; } }