Difference between revisions of "Comparator Assignment"

From CSE231 Wiki
Jump to navigation Jump to search
Line 1: Line 1:
 
=Background=
 
=Background=
 
[https://docs.oracle.com/javase/8/docs/api/java/util/Comparator.html Comparator<T>]
 
[https://docs.oracle.com/javase/8/docs/api/java/util/Comparator.html Comparator<T>]
 +
[https://docs.oracle.com/javase/8/docs/api/java/util/Optional.html Optional<T>]
 +
[https://www.cse.wustl.edu/~dennis.cosgrove/courses/cse231/fall21/apidocs/compare/core/HockeyPlayer.html HockeyPlayer]
 +
 
=Code To Implement=
 
=Code To Implement=
 
==CompareUtils==
 
==CompareUtils==

Revision as of 17:04, 2 November 2021

Background

Comparator<T> Optional<T> HockeyPlayer

Code To Implement

CompareUtils

min

public static <E> Optional<E> min(E[] array, Comparator<E> comparator)

CompareApps

closestTo

public static Optional<Integer> closestTo(Integer[] values, int target)

youngest

public static Optional<HockeyPlayer> youngest(HockeyPlayer[] players)

mostPoints

public static Optional<HockeyPlayer> mostPoints(HockeyPlayer[] players)