Stay organized with collections
Save and categorize content based on your preferences.
OfLong
interface OfLong : PrimitiveIterator<Long!, LongConsumer!>
An Iterator specialized for long
values.
Summary
Public methods |
open Unit |
Performs the given action for each remaining element until all elements have been processed or the action throws an exception.
|
open Unit |
Performs the given action for each remaining element until all elements have been processed or the action throws an exception.
|
open Long! |
Returns the next element in the iteration.
|
abstract Long |
Returns the next long element in the iteration.
|
Public methods
forEachRemaining
open fun forEachRemaining(action: Consumer<in Long!>): Unit
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.
The behavior of an iterator is unspecified if the action modifies the collection in any way (even by calling the remove
method or other mutator methods of Iterator
subtypes), unless an overriding class has specified a concurrent modification policy.
Subsequent behavior of an iterator is unspecified if the action throws an exception.
Parameters |
action |
Consumer<in Long!>: The action to be performed for each element |
Exceptions |
java.lang.NullPointerException |
if the specified action is null |
forEachRemaining
open fun forEachRemaining(action: LongConsumer!): Unit
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.
The behavior of an iterator is unspecified if the action modifies the source of elements in any way (even by calling the remove
method or other mutator methods of Iterator
subtypes), unless an overriding class has specified a concurrent modification policy.
Subsequent behavior of an iterator is unspecified if the action throws an exception.
Parameters |
action |
LongConsumer!: The action to be performed for each element |
Exceptions |
java.lang.NullPointerException |
if the specified action is null |
next
open fun next(): Long!
Returns the next element in the iteration.
Return |
Long! |
the next element in the iteration |
Exceptions |
java.util.NoSuchElementException |
if the iteration has no more elements |
nextLong
abstract fun nextLong(): Long
Returns the next long
element in the iteration.
Return |
Long |
the next long element in the iteration |
Exceptions |
java.util.NoSuchElementException |
if the iteration has no more elements |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-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 2025-02-10 UTC."],[],[],null,["# PrimitiveIterator.OfLong\n\nAdded in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nOfLong\n======\n\n```\ninterface OfLong : PrimitiveIterator\u003cLong!, LongConsumer!\u003e\n```\n\n|-----------------------------------------|\n| [java.util.PrimitiveIterator.OfLong](#) |\n\nAn Iterator specialized for `long` values.\n\nSummary\n-------\n\n| Public methods ||\n|---------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| open [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [forEachRemaining](#forEachRemaining(java.util.function.Consumer))`(`action:` `[Consumer](/reference/kotlin/java/util/function/Consumer)\u003cin` `[Long](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html)!\u003e`)` Performs the given action for each remaining element until all elements have been processed or the action throws an exception. |\n| open [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [forEachRemaining](#forEachRemaining(java.util.function.LongConsumer))`(`action:` `[LongConsumer](/reference/kotlin/java/util/function/LongConsumer)!`)` Performs the given action for each remaining element until all elements have been processed or the action throws an exception. |\n| open [Long](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html)! | [next](#next())`()` Returns the next element in the iteration. |\n| abstract [Long](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html) | [nextLong](#nextLong())`()` Returns the next `long` element in the iteration. |\n\nPublic methods\n--------------\n\n### forEachRemaining\n\nAdded in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun forEachRemaining(action: Consumer\u003cin Long!\u003e): Unit\n```\n\nPerforms 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.\n\nThe behavior of an iterator is unspecified if the action modifies the collection in any way (even by calling the [remove](/reference/kotlin/java/util/Iterator#remove()) method or other mutator methods of `Iterator` subtypes), unless an overriding class has specified a concurrent modification policy.\n\nSubsequent behavior of an iterator is unspecified if the action throws an exception.\n\n| Parameters ||\n|----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `action` | [Consumer](/reference/kotlin/java/util/function/Consumer)\\\u003cin [Long](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html)!\\\u003e: The action to be performed for each element |\n\n| Exceptions ||\n|----------------------------------|---------------------------------|\n| `java.lang.NullPointerException` | if the specified action is null |\n\n### forEachRemaining\n\nAdded in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun forEachRemaining(action: LongConsumer!): Unit\n```\n\nPerforms 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.\n\nThe behavior of an iterator is unspecified if the action modifies the source of elements in any way (even by calling the [remove](/reference/kotlin/java/util/Iterator#remove()) method or other mutator methods of `Iterator` subtypes), unless an overriding class has specified a concurrent modification policy.\n\nSubsequent behavior of an iterator is unspecified if the action throws an exception.\n\n| Parameters ||\n|----------|-----------------------------------------------------------------------------------------------------------------|\n| `action` | [LongConsumer](/reference/kotlin/java/util/function/LongConsumer)!: The action to be performed for each element |\n\n| Exceptions ||\n|----------------------------------|---------------------------------|\n| `java.lang.NullPointerException` | if the specified action is null |\n\n### next\n\nAdded in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun next(): Long!\n```\n\nReturns the next element in the iteration.\n\n| Return ||\n|-------------------------------------------------------------------------------|-----------------------------------|\n| [Long](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html)! | the next element in the iteration |\n\n| Exceptions ||\n|------------------------------------|---------------------------------------|\n| `java.util.NoSuchElementException` | if the iteration has no more elements |\n\n### nextLong\n\nAdded in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nabstract fun nextLong(): Long\n```\n\nReturns the next `long` element in the iteration.\n\n| Return ||\n|------------------------------------------------------------------------------|------------------------------------------|\n| [Long](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html) | the next `long` element in the iteration |\n\n| Exceptions ||\n|------------------------------------|---------------------------------------|\n| `java.util.NoSuchElementException` | if the iteration has no more elements |"]]