Implementation of Comparator.min and Comparator.max methods. Preliminary 
discussion is in this thread:
https://mail.openjdk.org/pipermail/core-libs-dev/2025-May/145638.html
The specification is mostly composed of Math.min/max and Collections.min/max 
specifications. 

The methods are quite trivial, so I don't think we need more extensive testing 
(e.g., using different comparators). But if you have ideas of new useful tests, 
I'll gladly add them.

I'm not sure whether we should specify exactly the behavior in case if the 
comparator returns 0. I feel that it could be a useful invariant that 
`Comparator.min(a, b)` and `Comparator.max(a, b)` always return different 
argument, partitioning the set of {a, b} objects (even if they are equal). But 
I'm open to suggestions here.

-------------

Commit messages:
 - Fix linebreaks
 - JDK-8356995 Provide default methods min(T, T) and max(T, T) in Comparator 
interface

Changes: https://git.openjdk.org/jdk/pull/25297/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=25297&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8356995
  Stats: 112 lines in 2 files changed: 110 ins; 1 del; 1 mod
  Patch: https://git.openjdk.org/jdk/pull/25297.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/25297/head:pull/25297

PR: https://git.openjdk.org/jdk/pull/25297

Reply via email to