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


Java PrimitiveIterator.OfLong方法代碼示例

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


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

示例1: iterate

import java.util.PrimitiveIterator; //導入方法依賴的package包/類
/**
 * Returns an infinite sequential ordered {@code LongStream} 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 LongStream} 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 LongStream}
 */
public static LongStream iterate(final long seed, final LongUnaryOperator f) {
    Objects.requireNonNull(f);
    final PrimitiveIterator.OfLong iterator = new PrimitiveIterator.OfLong() {
        long t = seed;

        @Override
        public boolean hasNext() {
            return true;
        }

        @Override
        public long nextLong() {
            long v = t;
            t = f.applyAsLong(t);
            return v;
        }
    };
    return StreamSupport.longStream(Spliterators.spliteratorUnknownSize(
            iterator,
            Spliterator.ORDERED | Spliterator.IMMUTABLE | Spliterator.NONNULL), false);
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:38,代碼來源:LongStream.java

示例2: testLongForEachRemainingWithNull

import java.util.PrimitiveIterator; //導入方法依賴的package包/類
public void testLongForEachRemainingWithNull() {
    PrimitiveIterator.OfLong i = new PrimitiveIterator.OfLong() {
        @Override
        public long nextLong() {
            return 0;
        }

        @Override
        public boolean hasNext() {
            return false;
        }
    };

    executeAndCatch(() -> i.forEachRemaining((LongConsumer) null));
    executeAndCatch(() -> i.forEachRemaining((Consumer<Long>) null));
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:17,代碼來源:PrimitiveIteratorDefaults.java

示例3: testLongForEachRemainingWithNull

import java.util.PrimitiveIterator; //導入方法依賴的package包/類
public void testLongForEachRemainingWithNull() {
    PrimitiveIterator.OfLong i = new PrimitiveIterator.OfLong() {
        @Override
        public long nextLong() {
            return 0;
        }

        @Override
        public boolean hasNext() {
            return false;
        }
    };

    assertThrowsNPE(() -> i.forEachRemaining((LongConsumer) null));
    assertThrowsNPE(() -> i.forEachRemaining((Consumer<Long>) null));
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:17,代碼來源:PrimitiveIteratorDefaults.java

示例4: iteratorOfLong

import java.util.PrimitiveIterator; //導入方法依賴的package包/類
/**
 * Returns a primitive iterator for this range
 * @return  the primitive iterator
 */
private PrimitiveIterator.OfLong iteratorOfLong() {
    return new PrimitiveIterator.OfLong() {
        private long 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 long nextLong() {
            final long next = value;
            value = ascend ? value + step : value - step;
            return next;
        }
    };
}
 
開發者ID:zavtech,項目名稱:morpheus-core,代碼行數:25,代碼來源:RangeOfLongs.java

示例5: iteratorVarLong

import java.util.PrimitiveIterator; //導入方法依賴的package包/類
PrimitiveIterator.OfLong iteratorVarLong(final int len) {
    return new PrimitiveIterator.OfLong() {
        private int i;
        private long x;
        @Override
        public boolean hasNext() {
            return i < len;
        }
        @Override
        public long nextLong() {
            remapIfNeeded();
            x += readVarLong(buff);
            return x;
        }
    };
}
 
開發者ID:thomasmueller,項目名稱:minperf,代碼行數:17,代碼來源:SortedSignatures.java

示例6: degenerateTree

import java.util.PrimitiveIterator; //導入方法依賴的package包/類
private Node.OfLong degenerateTree(PrimitiveIterator.OfLong it) {
    if (!it.hasNext()) {
        return Nodes.node(new long[0]);
    }

    long i = it.nextLong();
    if (it.hasNext()) {
        return new Nodes.ConcNode.OfLong(Nodes.node(new long[] {i}), degenerateTree(it));
    }
    else {
        return Nodes.node(new long[] {i});
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:14,代碼來源:LongNodeTest.java

示例7: iterator

import java.util.PrimitiveIterator; //導入方法依賴的package包/類
@Override
public final PrimitiveIterator.OfLong iterator() {
    return Spliterators.iterator(spliterator());
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:5,代碼來源:LongPipeline.java

示例8: iterator

import java.util.PrimitiveIterator; //導入方法依賴的package包/類
@Override
public PrimitiveIterator.OfLong iterator() {
    return Spliterators.iterator(spliterator());
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:5,代碼來源:SpinedBuffer.java

示例9: iterator

import java.util.PrimitiveIterator; //導入方法依賴的package包/類
@Override
PrimitiveIterator.OfLong iterator();
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:3,代碼來源:LongStream.java

示例10: iterator

import java.util.PrimitiveIterator; //導入方法依賴的package包/類
@Override
public PrimitiveIterator.OfLong iterator() {
    return s.iterator();
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:5,代碼來源:DefaultMethodStreams.java

示例11: iterator

import java.util.PrimitiveIterator; //導入方法依賴的package包/類
/**
 * {@inheritDoc}
 */
@Override
public PrimitiveIterator.OfLong iterator() {
    return pipeline.execute(LongIteratorTerminator.create(pipeline, parallel));
}
 
開發者ID:Pyknic,項目名稱:mutable-stream,代碼行數:8,代碼來源:MutableLongStream.java


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