public Optional < T > minByDouble ( ToDoubleFunction < ? super T > keyExtractor ) { return Box . asOptional ( reduce ( null , ( ObjDoubleBox < T > acc , T t ) -> { double val = keyExtractor . applyAsDouble ( t ) ; if ( acc == null ) return new ObjDoubleBox <> ( t , val ) ; if ( Double . compare ( val , acc . b ) < 0 ) { acc . b = val ; acc . a = t ; } return acc ; } , ( ObjDoubleBox < T > acc1 , ObjDoubleBox < T > acc2 ) -> ( acc1 == null || acc2 != null && Double . compare ( acc1 . b , acc2 . b ) > 0 ) ? acc2 : acc1 ) ) ; }
Returns the minimum element of this stream according to the double values extracted by provided function . This is a special case of a reduction .