Exemplo n.º 1
0
        public void TestSetAdd()
        {
            var iset = ImmutableHashSet.Create <int>(1, 2, 3);

            Assert.IsFalse(ImmutableUtils.TryAddOptimistically(ref iset, 3));
            Assert.IsTrue(ImmutableUtils.TryAddOptimistically(ref iset, 4));
        }
Exemplo n.º 2
0
        public void TestListAdd2()
        {
            const int c = 1000000;
            var       l = ImmutableList <int> .Empty;

            Parallel.For(0, c, i => ImmutableUtils.AddOptimistically(ref l, i));

            Assert.IsTrue(l.Count == c);
            Console.WriteLine(l.Count);
        }
Exemplo n.º 3
0
        public void TestSetAdd2()
        {
            const int c = 1000000;
            var       l = ImmutableHashSet <int> .Empty;

            Parallel.For(0, c, i => Assert.IsTrue(ImmutableUtils.TryAddOptimistically(ref l, i)));
            Parallel.For(0, c, i => Assert.IsFalse(ImmutableUtils.TryAddOptimistically(ref l, i)));

            Assert.IsTrue(l.Count == c);
            Console.WriteLine(l.Count);
        }