本文整理汇总了Java中java.util.function.DoubleConsumer.accept方法的典型用法代码示例。如果您正苦于以下问题:Java DoubleConsumer.accept方法的具体用法?Java DoubleConsumer.accept怎么用?Java DoubleConsumer.accept使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.function.DoubleConsumer
的用法示例。
在下文中一共展示了DoubleConsumer.accept方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: tryAdvance
import java.util.function.DoubleConsumer; //导入方法依赖的package包/类
@Override
public boolean tryAdvance(DoubleConsumer action) {
boolean test = true;
if (takeOrDrop && // If can take
checkCancelOnCount() && // and if not cancelled
s.tryAdvance(this) && // and if advanced one element
(test = p.test(t))) { // and test on element passes
action.accept(t); // then accept element
return true;
}
else {
// Taking is finished
takeOrDrop = false;
// Cancel all further traversal and splitting operations
// only if test of element failed (short-circuited)
if (!test)
cancel.set(true);
return false;
}
}
示例2: tryAdvance
import java.util.function.DoubleConsumer; //导入方法依赖的package包/类
public boolean tryAdvance(DoubleConsumer consumer) {
if (consumer == null) throw new NullPointerException();
long i = index, f = fence;
if (i < f) {
consumer.accept(rng.internalNextDouble(origin, bound));
index = i + 1;
return true;
}
return false;
}
示例3: tryAdvance
import java.util.function.DoubleConsumer; //导入方法依赖的package包/类
@Override
public boolean tryAdvance(DoubleConsumer action) {
Objects.requireNonNull(action);
if (count == -2) {
action.accept(first);
count = -1;
return true;
}
else {
return false;
}
}
示例4: tryAdvance
import java.util.function.DoubleConsumer; //导入方法依赖的package包/类
@Override
public boolean tryAdvance(DoubleConsumer action) {
if (action == null)
throw new NullPointerException();
if (index >= 0 && index < fence) {
action.accept(array[index++]);
return true;
}
return false;
}
示例5: tryAdvance
import java.util.function.DoubleConsumer; //导入方法依赖的package包/类
public boolean tryAdvance(DoubleConsumer consumer) {
if (consumer == null) throw new NullPointerException();
long i = index, f = fence;
if (i < f) {
consumer.accept(ThreadLocalRandom.current().internalNextDouble(origin, bound));
index = i + 1;
return true;
}
return false;
}
示例6: arrayForEach
import java.util.function.DoubleConsumer; //导入方法依赖的package包/类
@Override
protected void arrayForEach(double[] array,
int from, int to,
DoubleConsumer consumer) {
for (int i = from; i < to; i++)
consumer.accept(array[i]);
}
示例7: tryAdvance
import java.util.function.DoubleConsumer; //导入方法依赖的package包/类
@Override
public boolean tryAdvance(DoubleConsumer consumer) {
Objects.requireNonNull(consumer);
boolean hasNext = doAdvance();
if (hasNext)
consumer.accept(buffer.get(nextToConsume));
return hasNext;
}
示例8: tryAdvance
import java.util.function.DoubleConsumer; //导入方法依赖的package包/类
@Override
public boolean tryAdvance(DoubleConsumer action) {
Objects.requireNonNull(action);
action.accept(s.getAsDouble());
return true;
}
示例9: forEachRemaining
import java.util.function.DoubleConsumer; //导入方法依赖的package包/类
public void forEachRemaining(DoubleConsumer consumer) {
if (consumer == null) throw new NullPointerException();
long i = index, f = fence;
if (i < f) {
index = f;
Random r = rng;
double o = origin, b = bound;
do {
consumer.accept(r.internalNextDouble(o, b));
} while (++i < f);
}
}
示例10: forEachRemaining
import java.util.function.DoubleConsumer; //导入方法依赖的package包/类
public void forEachRemaining(DoubleConsumer consumer) {
if (consumer == null) throw new NullPointerException();
long i = index, f = fence;
if (i < f) {
index = f;
double o = origin, b = bound;
ThreadLocalRandom rng = ThreadLocalRandom.current();
do {
consumer.accept(rng.internalNextDouble(o, b));
} while (++i < f);
}
}
示例11: forEachRemaining
import java.util.function.DoubleConsumer; //导入方法依赖的package包/类
public void forEachRemaining(DoubleConsumer consumer) {
if (consumer == null) throw new NullPointerException();
long i = index, f = fence;
if (i < f) {
index = f;
SplittableRandom r = rng;
double o = origin, b = bound;
do {
consumer.accept(r.internalNextDouble(o, b));
} while (++i < f);
}
}
示例12: forEach
import java.util.function.DoubleConsumer; //导入方法依赖的package包/类
@Override
public void forEach(DoubleConsumer consumer) {
for (int i = 0; i < curSize; i++) {
consumer.accept(array[i]);
}
}
示例13: acceptConsumed
import java.util.function.DoubleConsumer; //导入方法依赖的package包/类
@Override
protected void acceptConsumed(DoubleConsumer action) {
action.accept(tmpValue);
}
示例14: forEach
import java.util.function.DoubleConsumer; //导入方法依赖的package包/类
@Override
void forEach(DoubleConsumer action, long fence) {
for (int i = 0; i < fence; i++) {
action.accept(array[i]);
}
}
示例15: forEachRemaining
import java.util.function.DoubleConsumer; //导入方法依赖的package包/类
/**
* Performs the given action for each remaining element until all elements
* have been processed or the action throws an exception. Actions are
* performed in the order of iteration, if that order is specified.
* Exceptions thrown by the action are relayed to the caller.
*
* @implSpec
* <p>The default implementation behaves as if:
* <pre>{@code
* while (hasNext())
* action.accept(nextDouble());
* }</pre>
*
* @param action The action to be performed for each element
* @throws NullPointerException if the specified action is null
*/
default void forEachRemaining(DoubleConsumer action) {
Objects.requireNonNull(action);
while (hasNext())
action.accept(nextDouble());
}