diff --git a/icu4j/main/core/src/main/java/com/ibm/icu/text/UnicodeSet.java b/icu4j/main/core/src/main/java/com/ibm/icu/text/UnicodeSet.java index cc97bbc840b9..a613f8a4e5cc 100644 --- a/icu4j/main/core/src/main/java/com/ibm/icu/text/UnicodeSet.java +++ b/icu4j/main/core/src/main/java/com/ibm/icu/text/UnicodeSet.java @@ -17,7 +17,12 @@ import java.util.Iterator; import java.util.NoSuchElementException; import java.util.SortedSet; +import java.util.Spliterator; import java.util.TreeSet; +import java.util.function.IntConsumer; +import java.util.stream.IntStream; +import java.util.stream.Stream; +import java.util.stream.StreamSupport; import com.ibm.icu.impl.BMPSet; import com.ibm.icu.impl.CharacterPropertiesImpl; @@ -278,14 +283,22 @@ * * * - *
To iterate over contents of UnicodeSet, the following are available: - *
To iterate over contents of {@code UnicodeSet}, the following are available: + *
The iterators and streams methods work as expected in idiomatic Java usage.
+ * The {@link UnicodeSetIterator} cannot be used in for loops, and it is not very Java-idiomatic, because it is old.
+ * But it might be faster in certain use cases. We recommend that you measure in performance sensitive code.
+ *
*
To replace, count elements, or delete spans, see {@link com.ibm.icu.text.UnicodeSetSpanner UnicodeSetSpanner}. * * @author Alan Liu @@ -5127,5 +5140,221 @@ public static void setDefaultXSymbolTable(XSymbolTable xSymbolTable) { CharacterPropertiesImpl.clear(); XSYMBOL_TABLE = xSymbolTable; } + + /** + * Returns a {@link Stream} of {@link EntryRange} values from this {@code UnicodeSet}. + * + *
Warnings: + *
Warnings: + *
Warnings: + *
Warnings: + *
Warnings: + *