Java Code Examples for java.util.PrimitiveIterator#OfLong

The following examples show how to use java.util.PrimitiveIterator#OfLong . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PrimitiveIteratorDefaults.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
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));
}
 
Example 2
Source File: PrimitiveIteratorDefaults.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
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));
}
 
Example 3
Source File: LongStream.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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 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);
}
 
Example 4
Source File: PrimitiveIteratorDefaults.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
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));
}
 
Example 5
Source File: PrimitiveIteratorDefaults.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
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));
}
 
Example 6
Source File: LongStream.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * 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);
}
 
Example 7
Source File: LongStream.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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 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);
}
 
Example 8
Source File: LongNodeTest.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
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});
    }
}
 
Example 9
Source File: LongNodeTest.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
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});
    }
}
 
Example 10
Source File: SpinedBuffer.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public PrimitiveIterator.OfLong iterator() {
    return Spliterators.iterator(spliterator());
}
 
Example 11
Source File: LongPipeline.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
@Override
public final PrimitiveIterator.OfLong iterator() {
    return Spliterators.iterator(spliterator());
}
 
Example 12
Source File: LongStream.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
@Override
PrimitiveIterator.OfLong iterator();
 
Example 13
Source File: LongPipeline.java    From JDKSourceCode1.8 with MIT License 4 votes vote down vote up
@Override
public final PrimitiveIterator.OfLong iterator() {
    return Spliterators.iterator(spliterator());
}
 
Example 14
Source File: LongStream.java    From JDKSourceCode1.8 with MIT License 4 votes vote down vote up
@Override
PrimitiveIterator.OfLong iterator();
 
Example 15
Source File: LongPipeline.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public final PrimitiveIterator.OfLong iterator() {
    return Spliterators.iterator(spliterator());
}
 
Example 16
Source File: TestData.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
@Override
public PrimitiveIterator.OfLong iterator() {
    return Spliterators.iterator(spliterator());
}
 
Example 17
Source File: LongStream.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
@Override
PrimitiveIterator.OfLong iterator();
 
Example 18
Source File: LongPipeline.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
@Override
public final PrimitiveIterator.OfLong iterator() {
    return Spliterators.iterator(spliterator());
}
 
Example 19
Source File: TestData.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
@Override
public PrimitiveIterator.OfLong iterator() {
    return Spliterators.iterator(spliterator());
}
 
Example 20
Source File: SpinedBuffer.java    From desugar_jdk_libs with GNU General Public License v2.0 4 votes vote down vote up
@Override
public PrimitiveIterator.OfLong iterator() {
    return Spliterators.iterator(spliterator());
}