Top Description Inners Methods
com.ibm.icu.util

public Interface ValueIterator

Known Direct Implementers
com.ibm.icu.lang.UCharacter.DummyValueIterator, com.ibm.icu.lang.UCharacterNameIterator

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);
}
Author
synwee
ICU Status
Stable since ICU 2.6.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
ValueIterator.Element

The return result container of each iteration.

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if we are not at the end of the iteration, false otherwise.
next
(ValueIterator.Element
for storing the result index and value
element
)

Returns the next result for this iteration and returns true if we are not at the end of the iteration, false otherwise.

public 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.

public void
setRange(int
first integer in the range to iterate
start
,
int
one more than the last integer in the range
limit
)

Restricts the range of integers to iterate and resets the iteration to begin at the index argument start.

Method Detail

nextback to summary
public 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.

ICU Status
Stable since ICU 2.6.
See Also
Element
resetback to summary
public 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.

ICU Status
Stable since ICU 2.6.
setRangeback to summary
public 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

Exceptions
IllegalArgumentException:
thrown when attempting to set an illegal range. E.g limit <= start
ICU Status
Stable since ICU 2.6.
com.ibm.icu.util back to summary

public final Class ValueIterator.Element

extends Object
Class Inheritance

The return result container of each iteration. Stores the next integer index and its associated value Object.

ICU Status
Stable since ICU 2.6.

Field Summary

Modifier and TypeField and Description
public int
integer

Integer index of the current iteration

public Object
value

Gets the Object value associated with the integer index.

Constructor Summary

AccessConstructor and Description
public
Element()

Empty default constructor to make javadoc happy

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

integerback to summary
public int integer

Integer index of the current iteration

ICU Status
Stable since ICU 2.6.
valueback to summary
public Object value

Gets the Object value associated with the integer index.

ICU Status
Stable since ICU 2.6.

Constructor Detail

Elementback to summary
public Element()

Empty default constructor to make javadoc happy

ICU Status
Stable since ICU 2.4.