java.util.function.DoubleSupplier#getAsDouble ( )源码实例Demo

下面列出了java.util.function.DoubleSupplier#getAsDouble ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: commons-geometry   文件: VectorPerformance.java
/** Set up the instance for the benchmark.
 */
@Setup(Level.Iteration)
public void setup() {
    vectors = new ArrayList<>(size);

    final double[] values = new double[dimension];
    final DoubleSupplier doubleSupplier = createDoubleSupplier(getType(),
            RandomSource.create(RandomSource.XO_RO_SHI_RO_128_PP));

    for (int i = 0; i < size; ++i) {
        for (int j = 0; j < dimension; ++j) {
            values[j] = doubleSupplier.getAsDouble();
        }

        vectors.add(vectorFactory.apply(values));
    }
}
 
源代码2 项目: commons-geometry   文件: SphereTest.java
@Test
public void testToTree_randomSpheres() {
    // arrange
    UniformRandomProvider rand = RandomSource.create(RandomSource.XO_RO_SHI_RO_128_PP, 1L);
    DoublePrecisionContext precision = new EpsilonDoublePrecisionContext(1e-10);
    double min = 1e-1;
    double max = 1e2;

    DoubleSupplier randDouble = () -> (rand.nextDouble() * (max - min)) + min;

    int count = 10;
    for (int i = 0; i < count; ++i) {
        Vector3D center = Vector3D.of(
                randDouble.getAsDouble(),
                randDouble.getAsDouble(),
                randDouble.getAsDouble());

        double radius = randDouble.getAsDouble();
        Sphere sphere = Sphere.from(center, radius, precision);

        for (int s = 0; s < 7; ++s) {
            // act
            RegionBSPTree3D tree = sphere.toTree(s);

            // assert
            Assert.assertEquals((int)(8 * Math.pow(4, s)), tree.getBoundaries().size());
            Assert.assertTrue(tree.isFinite());
            Assert.assertFalse(tree.isEmpty());
            Assert.assertTrue(tree.getSize() < sphere.getSize());
        }
    }
}
 
源代码3 项目: micrometer   文件: PostgreSQLDatabaseMetrics.java
/**
 * Function that makes sure functional counter values survive pg_stat_reset calls.
 */
Double resettableFunctionalCounter(String functionalCounterKey, DoubleSupplier function) {
    Double result = function.getAsDouble();
    Double previousResult = previousValueCacheMap.getOrDefault(functionalCounterKey, 0D);
    Double beforeResetValue = beforeResetValuesCacheMap.getOrDefault(functionalCounterKey, 0D);
    Double correctedValue = result + beforeResetValue;

    if (correctedValue < previousResult) {
        beforeResetValuesCacheMap.put(functionalCounterKey, previousResult);
        correctedValue = previousResult + result;
    }
    previousValueCacheMap.put(functionalCounterKey, correctedValue);
    return correctedValue;
}
 
源代码4 项目: micrometer   文件: TimeWindowMax.java
private double poll(DoubleSupplier maxSupplier) {
    rotate();
    synchronized (this) {
        return maxSupplier.getAsDouble();
    }
}
 
源代码5 项目: incubator-tuweni   文件: TomlTable.java
/**
 * Get a double from the TOML document, or return a default.
 *
 * @param path The key path.
 * @param defaultValue A supplier for the default value.
 * @return The value, or the default.
 * @throws TomlInvalidTypeException If the value is present but not a double, or any element of the path preceding the
 *         final key is not a table.
 */
default double getDouble(List<String> path, DoubleSupplier defaultValue) {
  requireNonNull(defaultValue);
  Double value = getDouble(path);
  if (value != null) {
    return value;
  }
  return defaultValue.getAsDouble();
}
 
源代码6 项目: cava   文件: TomlTable.java
/**
 * Get a double from the TOML document, or return a default.
 *
 * @param path The key path.
 * @param defaultValue A supplier for the default value.
 * @return The value, or the default.
 * @throws TomlInvalidTypeException If the value is present but not a double, or any element of the path preceding the
 *         final key is not a table.
 */
default double getDouble(List<String> path, DoubleSupplier defaultValue) {
  requireNonNull(defaultValue);
  Double value = getDouble(path);
  if (value != null) {
    return value;
  }
  return defaultValue.getAsDouble();
}
 
源代码7 项目: openjdk-8   文件: OptionalDouble.java
/**
 * Return the value if present, otherwise invoke {@code other} and return
 * the result of that invocation.
 *
 * @param other a {@code DoubleSupplier} whose result is returned if no value
 * is present
 * @return the value if present otherwise the result of {@code other.getAsDouble()}
 * @throws NullPointerException if value is not present and {@code other} is
 * null
 */
public double orElseGet(DoubleSupplier other) {
    return isPresent ? value : other.getAsDouble();
}
 
源代码8 项目: jdk1.8-source-analysis   文件: OptionalDouble.java
/**
 * Return the value if present, otherwise invoke {@code other} and return
 * the result of that invocation.
 *
 * @param other a {@code DoubleSupplier} whose result is returned if no value
 * is present
 * @return the value if present otherwise the result of {@code other.getAsDouble()}
 * @throws NullPointerException if value is not present and {@code other} is
 * null
 */
public double orElseGet(DoubleSupplier other) {
    return isPresent ? value : other.getAsDouble();
}
 
源代码9 项目: dragonwell8_jdk   文件: OptionalDouble.java
/**
 * Return the value if present, otherwise invoke {@code other} and return
 * the result of that invocation.
 *
 * @param other a {@code DoubleSupplier} whose result is returned if no value
 * is present
 * @return the value if present otherwise the result of {@code other.getAsDouble()}
 * @throws NullPointerException if value is not present and {@code other} is
 * null
 */
public double orElseGet(DoubleSupplier other) {
    return isPresent ? value : other.getAsDouble();
}
 
源代码10 项目: TencentKona-8   文件: OptionalDouble.java
/**
 * Return the value if present, otherwise invoke {@code other} and return
 * the result of that invocation.
 *
 * @param other a {@code DoubleSupplier} whose result is returned if no value
 * is present
 * @return the value if present otherwise the result of {@code other.getAsDouble()}
 * @throws NullPointerException if value is not present and {@code other} is
 * null
 */
public double orElseGet(DoubleSupplier other) {
    return isPresent ? value : other.getAsDouble();
}
 
源代码11 项目: jdk8u60   文件: OptionalDouble.java
/**
 * Return the value if present, otherwise invoke {@code other} and return
 * the result of that invocation.
 *
 * @param other a {@code DoubleSupplier} whose result is returned if no value
 * is present
 * @return the value if present otherwise the result of {@code other.getAsDouble()}
 * @throws NullPointerException if value is not present and {@code other} is
 * null
 */
public double orElseGet(DoubleSupplier other) {
    return isPresent ? value : other.getAsDouble();
}
 
源代码12 项目: JDKSourceCode1.8   文件: OptionalDouble.java
/**
 * Return the value if present, otherwise invoke {@code other} and return
 * the result of that invocation.
 *
 * @param other a {@code DoubleSupplier} whose result is returned if no value
 * is present
 * @return the value if present otherwise the result of {@code other.getAsDouble()}
 * @throws NullPointerException if value is not present and {@code other} is
 * null
 */
public double orElseGet(DoubleSupplier other) {
    return isPresent ? value : other.getAsDouble();
}
 
源代码13 项目: desugar_jdk_libs   文件: OptionalDouble.java
/**
 * Return the value if present, otherwise invoke {@code other} and return
 * the result of that invocation.
 *
 * @param other a {@code DoubleSupplier} whose result is returned if no value
 * is present
 * @return the value if present otherwise the result of {@code other.getAsDouble()}
 * @throws NullPointerException if value is not present and {@code other} is
 * null
 */
public double orElseGet(DoubleSupplier other) {
    return isPresent ? value : other.getAsDouble();
}
 
源代码14 项目: openjdk-jdk8u   文件: OptionalDouble.java
/**
 * Return the value if present, otherwise invoke {@code other} and return
 * the result of that invocation.
 *
 * @param other a {@code DoubleSupplier} whose result is returned if no value
 * is present
 * @return the value if present otherwise the result of {@code other.getAsDouble()}
 * @throws NullPointerException if value is not present and {@code other} is
 * null
 */
public double orElseGet(DoubleSupplier other) {
    return isPresent ? value : other.getAsDouble();
}
 
源代码15 项目: openjdk-jdk8u-backup   文件: OptionalDouble.java
/**
 * Return the value if present, otherwise invoke {@code other} and return
 * the result of that invocation.
 *
 * @param other a {@code DoubleSupplier} whose result is returned if no value
 * is present
 * @return the value if present otherwise the result of {@code other.getAsDouble()}
 * @throws NullPointerException if value is not present and {@code other} is
 * null
 */
public double orElseGet(DoubleSupplier other) {
    return isPresent ? value : other.getAsDouble();
}
 
源代码16 项目: Bytecoder   文件: OptionalDouble.java
/**
 * If a value is present, returns the value, otherwise returns the result
 * produced by the supplying function.
 *
 * @param supplier the supplying function that produces a value to be returned
 * @return the value, if present, otherwise the result produced by the
 *         supplying function
 * @throws NullPointerException if no value is present and the supplying
 *         function is {@code null}
 */
public double orElseGet(DoubleSupplier supplier) {
    return isPresent ? value : supplier.getAsDouble();
}
 
源代码17 项目: openjdk-8-source   文件: OptionalDouble.java
/**
 * Return the value if present, otherwise invoke {@code other} and return
 * the result of that invocation.
 *
 * @param other a {@code DoubleSupplier} whose result is returned if no value
 * is present
 * @return the value if present otherwise the result of {@code other.getAsDouble()}
 * @throws NullPointerException if value is not present and {@code other} is
 * null
 */
public double orElseGet(DoubleSupplier other) {
    return isPresent ? value : other.getAsDouble();
}
 
源代码18 项目: jdk8u_jdk   文件: OptionalDouble.java
/**
 * Return the value if present, otherwise invoke {@code other} and return
 * the result of that invocation.
 *
 * @param other a {@code DoubleSupplier} whose result is returned if no value
 * is present
 * @return the value if present otherwise the result of {@code other.getAsDouble()}
 * @throws NullPointerException if value is not present and {@code other} is
 * null
 */
public double orElseGet(DoubleSupplier other) {
    return isPresent ? value : other.getAsDouble();
}
 
源代码19 项目: Java8CN   文件: OptionalDouble.java
/**
 * Return the value if present, otherwise invoke {@code other} and return
 * the result of that invocation.
 *
 * @param other a {@code DoubleSupplier} whose result is returned if no value
 * is present
 * @return the value if present otherwise the result of {@code other.getAsDouble()}
 * @throws NullPointerException if value is not present and {@code other} is
 * null
 */
public double orElseGet(DoubleSupplier other) {
    return isPresent ? value : other.getAsDouble();
}
 
源代码20 项目: hottub   文件: OptionalDouble.java
/**
 * Return the value if present, otherwise invoke {@code other} and return
 * the result of that invocation.
 *
 * @param other a {@code DoubleSupplier} whose result is returned if no value
 * is present
 * @return the value if present otherwise the result of {@code other.getAsDouble()}
 * @throws NullPointerException if value is not present and {@code other} is
 * null
 */
public double orElseGet(DoubleSupplier other) {
    return isPresent ? value : other.getAsDouble();
}
 
 同类方法