code: public OptionalDouble maxByDouble(DoubleUnaryOperator keyExtractor) {
          double[] result = collect(() -> new double[3], (acc, d) -> {
              double key = keyExtractor.applyAsDouble(d);
              if (acc[2] == 0 || Double.compare(acc[1], key) < 0) {
                  acc[0] = d;
                  acc[1] = key;
                  acc[2] = 1;
              }
          }, (acc1, acc2) -> {
              if (acc2[2] == 1 && (acc1[2] == 0 || Double.compare(acc1[1], acc2[1]) < 0))
                  System.arraycopy(acc2, 0, acc1, 0, 3);
          });
          return result[2] == 1 ? OptionalDouble.of(result[0]) : OptionalDouble.empty();
      }
docs: Returns the maximum element of this stream according to the provided key
  extractor function.
  
  <p>
  This is a terminal operation.
  
  @param keyExtractor a non-interfering, stateless function
  @return an {@code OptionalDouble} describing the first element of this
  stream for which the highest value was returned by key extractor,
  or an empty {@code OptionalDouble} if the stream is empty
  @since 0.1.2