PrimitiveIterator.OfLong
Stay organized with collections
Save and categorize content based on your preferences.
An Iterator specialized for long
values.
Public Method Summary
void
|
forEachRemaining( LongConsumer action)
Performs the given action for each remaining element until all elements
have been processed or the action throws an exception.
|
void
|
|
Long
|
next()
Returns the next element in the iteration.
|
abstract
long
|
nextLong()
Returns the next long element in the iteration.
|
Inherited Method Summary
From interface
java.util.Iterator
void
|
forEachRemaining( Consumer<? super E> action)
Performs the given action for each remaining element until all elements
have been processed or the action throws an exception.
|
abstract
boolean
|
hasNext()
Returns true if the iteration has more elements.
|
abstract
Long
|
next()
Returns the next element in the iteration.
|
void
|
remove()
Removes from the underlying collection the last element returned
by this iterator (optional operation).
|
Public Methods
public
void
forEachRemaining
(LongConsumer action)
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.
Parameters
action |
The action to be performed for each element |
public
void
forEachRemaining
(Consumer<? super Long> action)
public
Long
next
()
Returns the next element in the iteration.
Returns
- the next element in the iteration
public
abstract
long
nextLong
()
Returns the next long
element in the iteration.
Returns
- the next
long
element in the iteration
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-07-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-07-10 UTC."],[[["\u003cp\u003e\u003ccode\u003ePrimitiveIterator.OfLong\u003c/code\u003e is a specialized iterator for handling \u003ccode\u003elong\u003c/code\u003e values in Java.\u003c/p\u003e\n"],["\u003cp\u003eIt provides methods like \u003ccode\u003enextLong()\u003c/code\u003e to retrieve the next \u003ccode\u003elong\u003c/code\u003e element and \u003ccode\u003eforEachRemaining()\u003c/code\u003e to process remaining elements.\u003c/p\u003e\n"],["\u003cp\u003eThis iterator inherits functionalities from \u003ccode\u003ePrimitiveIterator\u003c/code\u003e and \u003ccode\u003eIterator\u003c/code\u003e interfaces, offering methods for iteration control and element access.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003enextLong()\u003c/code\u003e throws \u003ccode\u003eNoSuchElementException\u003c/code\u003e if there are no more elements, while \u003ccode\u003eforEachRemaining()\u003c/code\u003e can relay exceptions thrown by the provided action.\u003c/p\u003e\n"]]],["`PrimitiveIterator.OfLong` is a specialized iterator for `long` values. Key actions include `nextLong()`, which retrieves the next `long` element, and `next()`, which returns the next element. The `forEachRemaining()` method applies a given action to each remaining element. `hasNext()` checks for more elements. It can throw a `NullPointerException` if the given action is null, and `NoSuchElementException` if there are no more elements.\n"],null,["# PrimitiveIterator.OfLong\n\npublic static interface **PrimitiveIterator.OfLong** implements [PrimitiveIterator](../../../reference/java/util/PrimitiveIterator.html)\\\u003c[Long](../../../reference/java/lang/Long.html), [LongConsumer](../../../reference/java/util/function/LongConsumer.html)\\\u003e \nAn Iterator specialized for `long` values. \n\n### Public Method Summary\n\n|------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| void | [forEachRemaining](../../../reference/java/util/PrimitiveIterator.OfLong.html#forEachRemaining(java.util.function.LongConsumer))([LongConsumer](../../../reference/java/util/function/LongConsumer.html) action) Performs the given action for each remaining element until all elements have been processed or the action throws an exception. |\n| void | [forEachRemaining](../../../reference/java/util/PrimitiveIterator.OfLong.html#forEachRemaining(java.util.function.Consumer\u003c?%20super%20java.lang.Long\u003e))([Consumer](../../../reference/java/util/function/Consumer.html)\\\u003c? super [Long](../../../reference/java/lang/Long.html)\\\u003e action) |\n| [Long](../../../reference/java/lang/Long.html) | [next](../../../reference/java/util/PrimitiveIterator.OfLong.html#next())() Returns the next element in the iteration. |\n| abstract long | [nextLong](../../../reference/java/util/PrimitiveIterator.OfLong.html#nextLong())() Returns the next `long` element in the iteration. |\n\n### Inherited Method Summary\n\nFrom interface [java.util.PrimitiveIterator](../../../reference/java/util/PrimitiveIterator.html) \n\n|---------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| abstract void | [forEachRemaining](../../../reference/java/util/PrimitiveIterator.html#forEachRemaining(T_CONS))([LongConsumer](../../../reference/java/util/function/LongConsumer.html) action) Performs the given action for each remaining element, in the order elements occur when iterating, until all elements have been processed or the action throws an exception. |\n\nFrom interface [java.util.Iterator](../../../reference/java/util/Iterator.html) \n\n|---------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| void | [forEachRemaining](../../../reference/java/util/Iterator.html#forEachRemaining(java.util.function.Consumer\u003c?%20super%20E\u003e))([Consumer](../../../reference/java/util/function/Consumer.html)\\\u003c? super E\\\u003e action) Performs the given action for each remaining element until all elements have been processed or the action throws an exception. |\n| abstract boolean | [hasNext](../../../reference/java/util/Iterator.html#hasNext())() Returns `true` if the iteration has more elements. |\n| abstract [Long](../../../reference/java/lang/Long.html) | [next](../../../reference/java/util/Iterator.html#next())() Returns the next element in the iteration. |\n| void | [remove](../../../reference/java/util/Iterator.html#remove())() Removes from the underlying collection the last element returned by this iterator (optional operation). |\n\nPublic Methods\n--------------\n\n#### public void\n**forEachRemaining**\n([LongConsumer](../../../reference/java/util/function/LongConsumer.html) action)\n\nPerforms the given action for each remaining element until all elements\nhave been processed or the action throws an exception. Actions are\nperformed in the order of iteration, if that order is specified.\nExceptions thrown by the action are relayed to the caller. \n\n##### Parameters\n\n| action | The action to be performed for each element |\n|--------|---------------------------------------------|\n\n##### Throws\n\n| [NullPointerException](../../../reference/java/lang/NullPointerException.html) | if the specified action is null |\n|--------------------------------------------------------------------------------|---------------------------------|\n\n#### public void\n**forEachRemaining**\n([Consumer](../../../reference/java/util/function/Consumer.html)\\\u003c? super [Long](../../../reference/java/lang/Long.html)\\\u003e action)\n\n\u003cbr /\u003e\n\n##### Parameters\n\n| action | |\n|--------|---|\n\n#### public [Long](../../../reference/java/lang/Long.html)\n**next**\n()\n\nReturns the next element in the iteration. \n\n##### Returns\n\n- the next element in the iteration \n\n#### public abstract long\n**nextLong**\n()\n\nReturns the next `long` element in the iteration. \n\n##### Returns\n\n- the next `long` element in the iteration \n\n##### Throws\n\n| [NoSuchElementException](../../../reference/java/util/NoSuchElementException.html) | if the iteration has no more elements |\n|------------------------------------------------------------------------------------|---------------------------------------|"]]