예제 #1
0
        public void CompactTest()
        {
            using (FileBackedHashSet <int> hashSet = new FileBackedHashSet <int>())
            {
                for (int i = 0; i < 10000; i += 4)
                {
                    hashSet.Add(i);

                    if (i % 100 == 0)
                    {
                        hashSet.Remove(i);
                    }

                    if (i % 400 == 0)
                    {
                        hashSet.Add(i);
                    }
                }

                hashSet.Compact();

                for (int i = 0; i < 10000; i++)
                {
                    if (i % 400 == 0)
                    {
                        Assert.IsTrue(hashSet.Contains(i));
                    }
                    else if (i % 100 == 0)
                    {
                        Assert.IsFalse(hashSet.Contains(i));
                    }
                    else if (i % 4 == 0)
                    {
                        Assert.IsTrue(hashSet.Contains(i));
                    }
                    else
                    {
                        Assert.IsFalse(hashSet.Contains(i));
                    }
                }
            }
        }
예제 #2
0
        public void CompactTest()
        {
            using (FileBackedHashSet<int> hashSet = new FileBackedHashSet<int>())
            {
                for (int i = 0; i < 10000; i += 4)
                {
                    hashSet.Add(i);

                    if (i % 100 == 0)
                        hashSet.Remove(i);

                    if (i % 400 == 0)
                        hashSet.Add(i);
                }

                hashSet.Compact();

                for (int i = 0; i < 10000; i++)
                {
                    if (i % 400 == 0)
                        Assert.IsTrue(hashSet.Contains(i));
                    else if (i % 100 == 0)
                        Assert.IsFalse(hashSet.Contains(i));
                    else if (i % 4 == 0)
                        Assert.IsTrue(hashSet.Contains(i));
                    else
                        Assert.IsFalse(hashSet.Contains(i));
                }
            }
        }