当前位置: 首页>>代码示例>>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;未经允许,请勿转载。