Ejemplo n.º 1
0
        public static void Distinct_SourceMultiple(ParallelQuery <int> query, int count)
        {
            int seen = 0;

            Assert.All(query.Distinct(), x => Assert.Equal(seen++, x));
            Assert.Equal(count, seen);
        }
Ejemplo n.º 2
0
        public static void Distinct_Unordered_NotPipelined(Labeled <ParallelQuery <int> > labeled, int count)
        {
            ParallelQuery <int> query = labeled.Item;
            IntegerRangeSet     seen  = new IntegerRangeSet(0, count);

            Assert.All(query.Distinct(new ModularCongruenceComparer(count)).ToList(), x => seen.Add(x % count));
            seen.AssertComplete();
        }
Ejemplo n.º 3
0
        public static void Distinct_NotPipelined(Labeled <ParallelQuery <int> > labeled, int count)
        {
            ParallelQuery <int> query = labeled.Item;
            int seen = 0;

            Assert.All(query.Distinct(new ModularCongruenceComparer(count)).ToList(), x => Assert.Equal(seen++, x % count));
            Assert.Equal(count, seen);
        }
Ejemplo n.º 4
0
        public static void Distinct(Labeled <ParallelQuery <int> > labeled, int count)
        {
            ParallelQuery <int> query = labeled.Item;
            int seen = 0;

            foreach (int i in query.Distinct(new ModularCongruenceComparer(count)))
            {
                Assert.Equal(seen++, i % count);
            }
            Assert.Equal(count, seen);
        }
Ejemplo n.º 5
0
        public static void Distinct_Unordered(Labeled <ParallelQuery <int> > labeled, int count)
        {
            ParallelQuery <int> query = labeled.Item;
            IntegerRangeSet     seen  = new IntegerRangeSet(0, count);

            foreach (int i in query.Distinct(new ModularCongruenceComparer(count)))
            {
                seen.Add(i % count);
            }
            seen.AssertComplete();
        }
Ejemplo n.º 6
0
        internal static ParallelQuery <int> MakeDistinct(bool orderPreserved)
        {
            List <int> list = new List <int>();

            for (int i = 1; i <= 100; i++)
            {
                list.Add(i); list.Add(i); list.Add(i);
            }
            int[] a = list.Concat(list).Concat(list).ToArray();

            ParallelQuery <int> ipe = a.AsParallel();

            if (orderPreserved)
            {
                ipe = ipe.AsOrdered();
            }

            return(ipe.Distinct());
        }
Ejemplo n.º 7
0
 public static IEnumerable <T> Distinct <T>(this ParallelQuery <T> list, Func <T, T, bool> distinctBy)
 {
     return(list.Distinct(new LambdaComparer <T>(distinctBy)));
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Returns distinct elements from a sequence of TLexical constructs by using a specified
 /// equality comparison function.
 /// </summary>
 /// <typeparam name="TLexical">Any type which implements the ILexical interface.</typeparam>
 /// <param name="elements">The sequence of TLexical constructs in which to eliminate duplicates.</param>
 /// <param name="comparison">A function to compare two TLexicals for equality.</param>
 /// <returns>
 /// A new sequence of ILexical constructs containing only the distinct elements of the
 /// source sequence as determined by the provided comparison function.
 /// </returns>
 /// <example>
 /// <code>
 /// var distinctNounPhrases = myDoc.Phrases
 ///     .AsParallel()
 ///     .OfNounPhrase()
 ///     .Distinct((np1, np2) =&gt; np1.Text == np2.Text || np1.IsAliasFor(np2));
 /// </code>
 /// </example>
 public static ParallelQuery <TLexical> Distinct <TLexical>(this ParallelQuery <TLexical> elements, Func <TLexical, TLexical, bool> comparison)
     where TLexical : ILexical => elements.Distinct(Equality.Create(comparison));
Ejemplo n.º 9
0
 public static void Distinct_SourceMultiple(ParallelQuery<int> query, int count)
 {
     int seen = 0;
     Assert.All(query.Distinct(), x => Assert.Equal(seen++, x));
     Assert.Equal(count, seen);
 }