Class MatchingUtils

java.lang.Object
org.tudalgo.algoutils.tutor.general.match.MatchingUtils

public class MatchingUtils extends Object
  • Constructor Details

    • MatchingUtils

      public MatchingUtils()
  • Method Details

    • matches

      public static <T> List<T> matches(Collection<T> objects, Matcher<? super T> matcher)

      Returns a list of all objects in the given collection matched by the given matcher sorted by match scores in descending order.

      Type Parameters:
      T - the type of objects
      Parameters:
      objects - the collection of objects
      matcher - the matcher
      Returns:
      the list of matched objects
    • firstMatch

      public static <T> T firstMatch(Collection<T> objects, Matcher<? super T> matcher)

      Returns the object in the given collection matched by the given matcher with the highest match score.

      If there is not such an object, null is returned.

      Type Parameters:
      T - the type of objects
      Parameters:
      objects - the collection of objects
      matcher - the matcher
      Returns:
      the matched object or null