當前位置: 首頁>>代碼示例>>Java>>正文


Java LongConsumer.accept方法代碼示例

本文整理匯總了Java中java.util.function.LongConsumer.accept方法的典型用法代碼示例。如果您正苦於以下問題:Java LongConsumer.accept方法的具體用法?Java LongConsumer.accept怎麽用?Java LongConsumer.accept使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.util.function.LongConsumer的用法示例。


在下文中一共展示了LongConsumer.accept方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: peek

import java.util.function.LongConsumer; //導入方法依賴的package包/類
@Override
public final LongStream peek(LongConsumer action) {
    Objects.requireNonNull(action);
    return new StatelessOp<Long>(this, StreamShape.LONG_VALUE,
                                 0) {
        @Override
        Sink<Long> opWrapSink(int flags, Sink<Long> sink) {
            return new Sink.ChainedLong<Long>(sink) {
                @Override
                public void accept(long t) {
                    action.accept(t);
                    downstream.accept(t);
                }
            };
        }
    };
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:18,代碼來源:LongPipeline.java

示例2: tryAdvance

import java.util.function.LongConsumer; //導入方法依賴的package包/類
@Override
public boolean tryAdvance(LongConsumer consumer) {
    Objects.requireNonNull(consumer);

    final long i = from;
    if (i < upTo) {
        from++;
        consumer.accept(i);
        return true;
    }
    else if (last > 0) {
        last = 0;
        consumer.accept(i);
        return true;
    }
    return false;
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:18,代碼來源:Streams.java

示例3: tryAdvance

import java.util.function.LongConsumer; //導入方法依賴的package包/類
@Override
public boolean tryAdvance(LongConsumer 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;
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:21,代碼來源:WhileOps.java

示例4: forEachRemaining

import java.util.function.LongConsumer; //導入方法依賴的package包/類
@Override
public void forEachRemaining(LongConsumer consumer) {
    Objects.requireNonNull(consumer);

    long i = from;
    final long hUpTo = upTo;
    int hLast = last;
    from = upTo;
    last = 0;
    while (i < hUpTo) {
        consumer.accept(i++);
    }
    if (hLast > 0) {
        // Last element of closed range
        consumer.accept(i);
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:18,代碼來源:Streams.java

示例5: forEachRemaining

import java.util.function.LongConsumer; //導入方法依賴的package包/類
@Override
public void forEachRemaining(LongConsumer action) {
    long[] a; int i, hi; // hoist accesses and checks from loop
    if (action == null)
        throw new NullPointerException();
    if ((a = array).length >= (hi = fence) &&
        (i = index) >= 0 && i < (index = hi)) {
        do { action.accept(a[i]); } while (++i < hi);
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:11,代碼來源:Spliterators.java

示例6: tryAdvance

import java.util.function.LongConsumer; //導入方法依賴的package包/類
@Override
public boolean tryAdvance(LongConsumer consumer) {
    Objects.requireNonNull(consumer);
    boolean hasNext = doAdvance();
    if (hasNext)
        consumer.accept(buffer.get(nextToConsume));
    return hasNext;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:9,代碼來源:StreamSpliterators.java

示例7: tryAdvance

import java.util.function.LongConsumer; //導入方法依賴的package包/類
public boolean tryAdvance(LongConsumer consumer) {
    if (consumer == null) throw new NullPointerException();
    long i = index, f = fence;
    if (i < f) {
        consumer.accept(rng.internalNextLong(origin, bound));
        index = i + 1;
        return true;
    }
    return false;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:11,代碼來源:SplittableRandom.java

示例8: arrayForEach

import java.util.function.LongConsumer; //導入方法依賴的package包/類
@Override
protected void arrayForEach(long[] array,
                            int from, int to,
                            LongConsumer consumer) {
    for (int i = from; i < to; i++)
        consumer.accept(array[i]);
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:8,代碼來源:SpinedBuffer.java

示例9: forEachRemaining

import java.util.function.LongConsumer; //導入方法依賴的package包/類
public void forEachRemaining(LongConsumer consumer) {
    if (consumer == null) throw new NullPointerException();
    long i = index, f = fence;
    if (i < f) {
        index = f;
        long o = origin, b = bound;
        ThreadLocalRandom rng = ThreadLocalRandom.current();
        do {
            consumer.accept(rng.internalNextLong(o, b));
        } while (++i < f);
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:13,代碼來源:ThreadLocalRandom.java

示例10: forEachRemaining

import java.util.function.LongConsumer; //導入方法依賴的package包/類
public void forEachRemaining(LongConsumer consumer) {
    if (consumer == null) throw new NullPointerException();
    long i = index, f = fence;
    if (i < f) {
        index = f;
        Random r = rng;
        long o = origin, b = bound;
        do {
            consumer.accept(r.internalNextLong(o, b));
        } while (++i < f);
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:13,代碼來源:Random.java

示例11: tryAdvance

import java.util.function.LongConsumer; //導入方法依賴的package包/類
@Override
public boolean tryAdvance(LongConsumer action) {
    if (action == null)
        throw new NullPointerException();
    if (index >= 0 && index < fence) {
        action.accept(array[index++]);
        return true;
    }
    return false;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:11,代碼來源:Spliterators.java

示例12: tryAdvance

import java.util.function.LongConsumer; //導入方法依賴的package包/類
public boolean tryAdvance(LongConsumer consumer) {
    if (consumer == null) throw new NullPointerException();
    long i = index, f = fence;
    if (i < f) {
        consumer.accept(ThreadLocalRandom.current().internalNextLong(origin, bound));
        index = i + 1;
        return true;
    }
    return false;
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:11,代碼來源:ThreadLocalRandom.java

示例13: tryAdvance

import java.util.function.LongConsumer; //導入方法依賴的package包/類
@Override
public boolean tryAdvance(LongConsumer action) {
    if (action == null) throw new NullPointerException();
    if (it.hasNext()) {
        action.accept(it.nextLong());
        return true;
    }
    return false;
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:10,代碼來源:Spliterators.java

示例14: forEach

import java.util.function.LongConsumer; //導入方法依賴的package包/類
@Override
public void forEach(LongConsumer consumer) {
    for (int i = 0; i < curSize; i++) {
        consumer.accept(array[i]);
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:7,代碼來源:Nodes.java

示例15: acceptConsumed

import java.util.function.LongConsumer; //導入方法依賴的package包/類
@Override
protected void acceptConsumed(LongConsumer action) {
    action.accept(tmpValue);
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:5,代碼來源:StreamSpliterators.java


注:本文中的java.util.function.LongConsumer.accept方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。