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