ValueIterator
public
interface
ValueIterator
android.icu.util.ValueIterator
|
Interface for enabling iteration over sets of <int, Object>, where
int is the sorted integer index in ascending order, and Object its
associated value.
The ValueIterator allows iterations over integer indexes in the range
of Integer.MIN_VALUE to Integer.MAX_VALUE inclusive. Implementations of
ValueIterator should specify their own maximum subrange within the above
range that is meaningful to its applications.
Most implementations will be created by factory methods, such as the
character name iterator in UCharacter.getNameIterator. See example below.
Example of use:
ValueIterator iterator = UCharacter.getNameIterator();
ValueIterator.Element result = new ValueIterator.Element();
iterator.setRange(UCharacter.MIN_VALUE, UCharacter.MAX_VALUE);
while (iterator.next(result)) {
System.out.println("Codepoint \\u" +
Integer.toHexString(result.integer) +
" has the character name " + (String)result.value);
}
Summary
Nested classes |
class |
ValueIterator.Element
The return result container of each iteration.
|
Public methods |
abstract
boolean
|
next(ValueIterator.Element element)
Returns the next result for this iteration and returns
true if we are not at the end of the iteration, false otherwise.
|
abstract
void
|
reset()
Resets the iterator to start iterating from the integer index
Integer.MIN_VALUE or X if a setRange(X, Y) has been called previously.
|
abstract
void
|
setRange(int start, int limit)
Restricts the range of integers to iterate and resets the iteration
to begin at the index argument start.
|
Public methods
next
public abstract boolean next (ValueIterator.Element element)
Returns the next result for this iteration and returns
true if we are not at the end of the iteration, false otherwise.
If this returns a false, the contents of elements will not
be updated.
Parameters |
element |
ValueIterator.Element : for storing the result index and value |
Returns |
boolean |
true if we are not at the end of the iteration, false otherwise. |
reset
public abstract void reset ()
Resets the iterator to start iterating from the integer index
Integer.MIN_VALUE or X if a setRange(X, Y) has been called previously.
setRange
public abstract void setRange (int start,
int limit)
Restricts the range of integers to iterate and resets the iteration
to begin at the index argument start.
If setRange(start, end) is not performed before next(element) is
called, the iteration will start from the integer index
Integer.MIN_VALUE and end at Integer.MAX_VALUE.
If this range is set outside the meaningful range specified by the
implementation, next(element) will always return false.
Parameters |
start |
int : first integer in the range to iterate |
limit |
int : one more than the last integer in the range |
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,["# ValueIterator\n\nAdded in [API level 24](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\nValueIterator\n=============\n\n*** ** * ** ***\n\n[Kotlin](/reference/kotlin/android/icu/util/ValueIterator \"View this page in Kotlin\") \\|Java\n\n\n`\npublic\n\n\ninterface\nValueIterator\n`\n\n\n`\n\n\n`\n\n|--------------------------------|\n| android.icu.util.ValueIterator |\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\n\u003cbr /\u003e\n\nInterface for enabling iteration over sets of \\\u003cint, Object\\\u003e, where\nint is the sorted integer index in ascending order, and Object its\nassociated value.\n\nThe ValueIterator allows iterations over integer indexes in the range\nof Integer.MIN_VALUE to Integer.MAX_VALUE inclusive. Implementations of\nValueIterator should specify their own maximum subrange within the above\nrange that is meaningful to its applications.\n\nMost implementations will be created by factory methods, such as the\ncharacter name iterator in UCharacter.getNameIterator. See example below.\n\nExample of use: \n\n```\n ValueIterator iterator = UCharacter.getNameIterator();\n ValueIterator.Element result = new ValueIterator.Element();\n iterator.setRange(UCharacter.MIN_VALUE, UCharacter.MAX_VALUE);\n while (iterator.next(result)) {\n System.out.println(\"Codepoint \\\\u\" +\n Integer.toHexString(result.integer) +\n \" has the character name \" + (String)result.value);\n }\n \n```\n\n\u003cbr /\u003e\n\nSummary\n-------\n\n| ### Nested classes ||\n|----------|----------------------------------------------------------------------------------------------------------------------------------|\n| ` class` | [ValueIterator.Element](/reference/android/icu/util/ValueIterator.Element) \u003cbr /\u003e The return result container of each iteration. |\n\n| ### Public methods ||\n|---------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ` abstract boolean` | ` `[next](/reference/android/icu/util/ValueIterator#next(android.icu.util.ValueIterator.Element))`(`[ValueIterator.Element](/reference/android/icu/util/ValueIterator.Element)` element) ` \u003cbr /\u003e Returns the next result for this iteration and returns true if we are not at the end of the iteration, false otherwise. |\n| ` abstract void` | ` `[reset](/reference/android/icu/util/ValueIterator#reset())`() ` \u003cbr /\u003e Resets the iterator to start iterating from the integer index Integer.MIN_VALUE or X if a setRange(X, Y) has been called previously. |\n| ` abstract void` | ` `[setRange](/reference/android/icu/util/ValueIterator#setRange(int,%20int))`(int start, int limit) ` \u003cbr /\u003e Restricts the range of integers to iterate and resets the iteration to begin at the index argument start. |\n\nPublic methods\n--------------\n\n### next\n\nAdded in [API level 24](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic abstract boolean next (ValueIterator.Element element)\n```\n\n\u003cbr /\u003e\n\nReturns the next result for this iteration and returns\ntrue if we are not at the end of the iteration, false otherwise.\n\nIf this returns a false, the contents of elements will not\nbe updated.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|-----------|------------------------------------------------------------------------|\n| `element` | `ValueIterator.Element`: for storing the result index and value \u003cbr /\u003e |\n\n| Returns ||\n|-----------|-------------------------------------------------------------------------|\n| `boolean` | true if we are not at the end of the iteration, false otherwise. \u003cbr /\u003e |\n\n**See also:**\n\n- [ValueIterator.Element](/reference/android/icu/util/ValueIterator.Element) \n\n### reset\n\nAdded in [API level 24](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic abstract void reset ()\n```\n\n\u003cbr /\u003e\n\nResets the iterator to start iterating from the integer index\nInteger.MIN_VALUE or X if a setRange(X, Y) has been called previously.\n\n\u003cbr /\u003e\n\n### setRange\n\nAdded in [API level 24](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic abstract void setRange (int start, \n int limit)\n```\n\n\u003cbr /\u003e\n\nRestricts the range of integers to iterate and resets the iteration\nto begin at the index argument start.\n\nIf setRange(start, end) is not performed before next(element) is\ncalled, the iteration will start from the integer index\nInteger.MIN_VALUE and end at Integer.MAX_VALUE.\n\n\nIf this range is set outside the meaningful range specified by the\nimplementation, next(element) will always return false.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|---------|-----------------------------------------------------------|\n| `start` | `int`: first integer in the range to iterate \u003cbr /\u003e |\n| `limit` | `int`: one more than the last integer in the range \u003cbr /\u003e |\n\n| Throws ||\n|---------------------------------------------------------------------------|---------------------------------------------------------------------|\n| [IllegalArgumentException](/reference/java/lang/IllegalArgumentException) | thrown when attempting to set an illegal range. E.g limit \\\u003c= start |"]]