Example #1
0
        public void BenchmarkCuckooTestAndRemove()
        {
            var n    = 100000u;
            var f    = new CuckooBloomFilter(n, 0.1);
            var data = new byte[n][];

            for (int i = 0; i < n; i++)
            {
                data[i] = Encoding.ASCII.GetBytes(i.ToString());
            }

            for (int i = 0; i < n; i++)
            {
                f.TestAndRemove(data[i]);
            }
        }
Example #2
0
        public void TestCuckooCount()
        {
            var f = new CuckooBloomFilter(100, 0.1);

            for (int i = 0; i < 10; i++)
            {
                f.Add(Encoding.ASCII.GetBytes(i.ToString()));
            }

            for (int i = 0; i < 5; i++)
            {
                f.TestAndRemove(Encoding.ASCII.GetBytes(i.ToString()));
            }

            var count = f.Count();

            Assert.AreEqual(5u, count);
        }
Example #3
0
        public void TestCuckooTestAndRemove()
        {
            var f = new CuckooBloomFilter(100, 0.1);

            // 'a' is not in the filter.
            if (f.Test(A_BYTES))
            {
                Assert.Fail("'a' should not be a member");
            }

            f.Add(A_BYTES);

            // 'a' is now in the filter.
            if (!f.TestAndRemove(A_BYTES))
            {
                Assert.Fail("'a' should be a member");
            }

            // 'a' is no longer in the filter.
            if (f.Test(A_BYTES))
            {
                Assert.Fail("'a' should not be a member");
            }
        }