本文整理匯總了Java中java.util.PrimitiveIterator.OfDouble方法的典型用法代碼示例。如果您正苦於以下問題:Java PrimitiveIterator.OfDouble方法的具體用法?Java PrimitiveIterator.OfDouble怎麽用?Java PrimitiveIterator.OfDouble使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.util.PrimitiveIterator
的用法示例。
在下文中一共展示了PrimitiveIterator.OfDouble方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: iterate
import java.util.PrimitiveIterator; //導入方法依賴的package包/類
/**
* Returns an infinite sequential ordered {@code DoubleStream} produced by iterative
* application of a function {@code f} to an initial element {@code seed},
* producing a {@code Stream} consisting of {@code seed}, {@code f(seed)},
* {@code f(f(seed))}, etc.
*
* <p>The first element (position {@code 0}) in the {@code DoubleStream}
* will be the provided {@code seed}. For {@code n > 0}, the element at
* position {@code n}, will be the result of applying the function {@code f}
* to the element at position {@code n - 1}.
*
* @param seed the initial element
* @param f a function to be applied to to the previous element to produce
* a new element
* @return a new sequential {@code DoubleStream}
*/
public static DoubleStream iterate(final double seed, final DoubleUnaryOperator f) {
Objects.requireNonNull(f);
final PrimitiveIterator.OfDouble iterator = new PrimitiveIterator.OfDouble() {
double t = seed;
@Override
public boolean hasNext() {
return true;
}
@Override
public double nextDouble() {
double v = t;
t = f.applyAsDouble(t);
return v;
}
};
return StreamSupport.doubleStream(Spliterators.spliteratorUnknownSize(
iterator,
Spliterator.ORDERED | Spliterator.IMMUTABLE | Spliterator.NONNULL), false);
}
示例2: iteratorOfDouble
import java.util.PrimitiveIterator; //導入方法依賴的package包/類
/**
* Returns a primitive iterator for this range
* @return the primitive iterator
*/
private PrimitiveIterator.OfDouble iteratorOfDouble() {
return new PrimitiveIterator.OfDouble() {
private double value = start;
@Override
public boolean hasNext() {
if (excludes != null) {
while (excludes.test(value) && inBounds(value)) {
value = ascend ? value + step : value - step;
}
}
return inBounds(value);
}
@Override
public double nextDouble() {
final double next = value;
value = ascend ? value + step : value - step;
return next;
}
};
}
示例3: testDoubleForEachRemainingWithNull
import java.util.PrimitiveIterator; //導入方法依賴的package包/類
public void testDoubleForEachRemainingWithNull() {
PrimitiveIterator.OfDouble i = new PrimitiveIterator.OfDouble() {
@Override
public double nextDouble() {
return 0;
}
@Override
public boolean hasNext() {
return false;
}
};
executeAndCatch(() -> i.forEachRemaining((DoubleConsumer) null));
executeAndCatch(() -> i.forEachRemaining((Consumer<Double>) null));
}
示例4: testDoubleForEachRemainingWithNull
import java.util.PrimitiveIterator; //導入方法依賴的package包/類
public void testDoubleForEachRemainingWithNull() {
PrimitiveIterator.OfDouble i = new PrimitiveIterator.OfDouble() {
@Override
public double nextDouble() {
return 0;
}
@Override
public boolean hasNext() {
return false;
}
};
assertThrowsNPE(() -> i.forEachRemaining((DoubleConsumer) null));
assertThrowsNPE(() -> i.forEachRemaining((Consumer<Double>) null));
}
示例5: calculateRegionInfo
import java.util.PrimitiveIterator; //導入方法依賴的package包/類
/** {@inheritDoc} */
@Override public VarianceData calculateRegionInfo(DoubleStream s, int size) {
PrimitiveIterator.OfDouble itr = s.iterator();
int i = 0;
double mean = 0.0;
double m2 = 0.0;
// Here we calculate variance and mean by incremental computation.
while (itr.hasNext()) {
i++;
double x = itr.next();
double delta = x - mean;
mean += delta / i;
double delta2 = x - mean;
m2 += delta * delta2;
}
return new VarianceData(m2 / i, size, mean);
}
示例6: rowMajor
import java.util.PrimitiveIterator; //導入方法依賴的package包/類
public PrimitiveIterator.OfDouble rowMajor() {
return new PrimitiveIterator.OfDouble() {
int idx = 0;
public boolean hasNext() {
return idx < 16;
}
public double nextDouble() {
if (idx < 9) {
return elements[idx++];
} else {
throw new NoSuchElementException();
}
}
};
}
示例7: rowMajor
import java.util.PrimitiveIterator; //導入方法依賴的package包/類
public PrimitiveIterator.OfDouble rowMajor() {
return new PrimitiveIterator.OfDouble() {
int idx = 0;
public boolean hasNext() {
return idx < 9;
}
public double nextDouble() {
if (idx < 9) {
return elements[idx++];
} else {
throw new NoSuchElementException();
}
}
};
}
示例8: degenerateTree
import java.util.PrimitiveIterator; //導入方法依賴的package包/類
private Node.OfDouble degenerateTree(PrimitiveIterator.OfDouble it) {
if (!it.hasNext()) {
return Nodes.node(new double[0]);
}
double i = it.nextDouble();
if (it.hasNext()) {
return new Nodes.ConcNode.OfDouble(Nodes.node(new double[] {i}), degenerateTree(it));
}
else {
return Nodes.node(new double[] {i});
}
}
示例9: iterator
import java.util.PrimitiveIterator; //導入方法依賴的package包/類
@Override
public final PrimitiveIterator.OfDouble iterator() {
return Spliterators.iterator(spliterator());
}
示例10: iterator
import java.util.PrimitiveIterator; //導入方法依賴的package包/類
@Override
public PrimitiveIterator.OfDouble iterator() {
return Spliterators.iterator(spliterator());
}
示例11: iterator
import java.util.PrimitiveIterator; //導入方法依賴的package包/類
@Override
PrimitiveIterator.OfDouble iterator();
示例12: iterator
import java.util.PrimitiveIterator; //導入方法依賴的package包/類
@Override
public PrimitiveIterator.OfDouble iterator() {
return s.iterator();
}
示例13: calculateRegionInfo
import java.util.PrimitiveIterator; //導入方法依賴的package包/類
/** {@inheritDoc} */
@Override public GiniData calculateRegionInfo(DoubleStream s, int l) {
PrimitiveIterator.OfDouble itr = s.iterator();
Map<Double, Integer> m = new HashMap<>();
int size = 0;
while (itr.hasNext()) {
size++;
m.compute(itr.next(), (a, i) -> i != null ? i + 1 : 1);
}
double c2 = m.values().stream().mapToDouble(v -> v * v).sum();
int[] cnts = new int[mapping.size()];
m.forEach((key, value) -> cnts[mapping.get(key)] = value);
return new GiniData(size != 0 ? 1 - c2 / (size * size) : 0.0, size, cnts, c2);
}
示例14: columnMajor
import java.util.PrimitiveIterator; //導入方法依賴的package包/類
public PrimitiveIterator.OfDouble columnMajor() {
return transpose().rowMajor();
}
示例15: execute
import java.util.PrimitiveIterator; //導入方法依賴的package包/類
@Override
public PrimitiveIterator.OfDouble execute() {
try (final DoubleStream stream = buildPrevious()) {
return stream.iterator();
}
}