Example #1
0
        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));
            }
        }
Example #2
0
        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));
            }
        }
Example #3
0
        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));
            }
        }
Example #4
0
        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));
            }
        }