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))); }
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))); }
public static void Contains_MultipleMatching(Labeled <ParallelQuery <int> > labeled, int count) { ParallelQuery <int> query = labeled.Item; Assert.True(query.Contains(count, new ModularCongruenceComparer(2))); }
/// <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) => 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));