Is there a concise way to extract both the min and max value of a stream (based on some comparator) in one pass?
There appear to be many ways to get the min and max
For a pure Java solution that's fairly concise, you can use .peek(). This is not truly Functional, as anything that .peek() does is a side-effect. But this does do it all in one pass, doesn't require sorting and isn't too verbose. There is a "temp" Object, the AtomicRef, but you'll probably allocate a local var/ref to hold the min and max anyway.
Comparator cmp = ...
Stream source = ...
final AtomicReference min = new AtomicReference();
Optional max = source.peek(t -> {if (cmp.compare(t,min.get()) < 0) min.set(t);})
.max(cmp);
//Do whatever with min.get() and max.get()