示例#1
0
        public void RemoveNonExistingTest()
        {
            System.Collections.Immutable.IImmutableSet <int> emptySet = this.Empty <int>();
            Assert.True(IsSame(emptySet, emptySet.Remove(5)));

            // Also fill up a set with many elements to build up the tree, then remove from various places in the tree.
            const int Size = 200;
            var       set  = emptySet;

            for (int i = 0; i < Size; i += 2)
            { // only even numbers!
                set = set.Add(i);
            }

            // Verify that removing odd numbers doesn't change anything.
            for (int i = 1; i < Size; i += 2)
            {
                var setAfterRemoval = set.Remove(i);
                Assert.True(IsSame(set, setAfterRemoval));
            }
        }
示例#2
0
        private static void RemoveTestHelper <T>(System.Collections.Immutable.IImmutableSet <T> set, params T[] values)
        {
            Assert.NotNull(set);
            Assert.NotNull(values);

            Assert.True(IsSame(set, set.Except(Enumerable.Empty <T>())));

            int initialCount = set.Count;
            int removedCount = 0;

            foreach (T value in values)
            {
                var nextSet = set.Remove(value);
                Assert.NotSame(set, nextSet);
                Assert.Equal(initialCount - removedCount, set.Count);
                Assert.Equal(initialCount - removedCount - 1, nextSet.Count);

                Assert.True(IsSame(nextSet, nextSet.Remove(value))); //, "Removing a non-existing element should not change the set reference.");
                removedCount++;
                set = nextSet;
            }

            Assert.Equal(initialCount - removedCount, set.Count);
        }
示例#3
0
        private static void AddRemoveLoadTestHelper <T>(System.Collections.Immutable.IImmutableSet <T> set, T[] data)
        {
            Assert.NotNull(set);
            Assert.NotNull(data);

            foreach (T value in data)
            {
                var newSet = set.Add(value);
                Assert.NotSame(set, newSet);
                set = newSet;
            }

            foreach (T value in data)
            {
                Assert.True(set.Contains(value));
            }

            foreach (T value in data)
            {
                var newSet = set.Remove(value);
                Assert.NotSame(set, newSet);
                set = newSet;
            }
        }
 private void RemoveFileFromList(System.String file)
 {
     System.Collections.Immutable.IImmutableSet <System.String> res;
     System.Collections.Immutable.IImmutableSet <System.String> original;
     while (myFilePathName.Contains(file))
     {
         do
         {
             original = myFilePathName;
             res      = System.Threading.Interlocked.CompareExchange <System.Collections.Immutable.IImmutableSet <System.String> >(ref myFilePathName, myFilePathName.Remove(file), original);
         } while (myFilePathName.Contains(file));
     }
 }