Пример #1
0
        public static void Contains_OneMatching(Labeled <ParallelQuery <int> > labeled, int count, int position)
        {
            ParallelQuery <int> query = labeled.Item;

            Assert.True(query.Contains(position));
            Assert.True(query.Contains(position, null));
            Assert.True(query.Contains(position, new ModularCongruenceComparer(count)));
        }
Пример #2
0
        public static void Contains_NoMatching(Labeled <ParallelQuery <int> > labeled, int count)
        {
            ParallelQuery <int> query = labeled.Item;

            Assert.False(query.Contains(count));
            Assert.False(query.Contains(count, null));
            Assert.False(query.Contains(count, new ModularCongruenceComparer(count + 1)));
        }
Пример #3
0
        public static void Contains_MultipleMatching(Labeled <ParallelQuery <int> > labeled, int count)
        {
            ParallelQuery <int> query = labeled.Item;

            Assert.True(query.Contains(count, new ModularCongruenceComparer(2)));
        }
Пример #4
0
 /// <summary>
 /// Determines whether a sequence of ILexical constructs contains a specified element by
 /// using a specified equality comparison function.
 /// </summary>
 /// <param name="elements">
 /// The sequence of ILexical constructs in which to search for the given element.
 /// </param>
 /// <param name="element">The element to search for.</param>
 /// <param name="equate">A function to compare two ILexicals for equality.</param>
 /// <typeparam name="TLexical">Any type which implements the ILexical interface.</typeparam>
 /// <returns><c>true</c> if the sequence contains the given element; otherwise, <c>false</c>.</returns>
 /// <example>
 /// <code>
 /// var myNPs = myDoc.Phrases.OfNounPhrase();
 /// if (myNPs.Contains(NpToFind, (np1, np2) =&gt; np1.Text == np2.Text || np1.IsAliasFor(np2)))
 /// {
 ///     Console.WriteLine("Found!");
 /// }
 /// </code>
 /// </example>
 public static bool Contains <TLexical>(this ParallelQuery <TLexical> elements, TLexical element, Func <TLexical, TLexical, bool> equate)
     where TLexical : ILexical => elements.Contains(element, Equality.Create(equate));