CodePointIndexedIterator

An iterator for traversing Unicode code points bidirectionally within a text.

This interface extends the capabilities of CodePointIterator by adding support for reverse iteration and positional control.

Functionalities provided by this iterator include:

  • Determining if there are more code points to iterate in either forward or reverse direction: hasNext, hasPrevious.

  • Determining the char position of the next or previous code point: nextIndex, previousIndex.

  • Retrieving the next or previous code point using next and previous functions.

  • Advancing the iteration by a specified number of code points in either direction: advanceByCodePoints.

The iterator can be obtained from a String, CharSequence, or CharArray using the codePointIterator function.

Since Kotlin

2.5

Functions

Link copied to clipboard
abstract fun advanceByCodePoints(codePointOffset: Int)

Advances the iterator by the specified number of Unicode code points, either forward or backward.

Since Kotlin 2.5
Link copied to clipboard

Creates a sequence that returns all elements from this iterator. The sequence is constrained to be iterated only once.

Since Kotlin 1.0
Link copied to clipboard
inline fun <T> Iterator<T>.forEach(operation: (T) -> Unit)

Performs the given operation on each element of this Iterator.

Since Kotlin 1.0
Link copied to clipboard
abstract operator override fun hasNext(): Boolean

Returns true if the iterator can return more code points when iterating in forward direction.

Since Kotlin 2.5
Link copied to clipboard
abstract fun hasPrevious(): Boolean

Returns true if the iterator can return more code points when iterating in reverse direction.

Since Kotlin 2.5
Link copied to clipboard
inline operator fun <T> Iterator<T>.iterator(): Iterator<T>

Returns the given iterator itself. This allows to use an instance of iterator in a for loop.

Since Kotlin 1.0
Link copied to clipboard
abstract operator override fun next(): CodePoint

Returns the next code point in the iteration and advances the iteration position forward by one code point.

Since Kotlin 2.5
Link copied to clipboard
abstract fun nextIndex(): Int

Returns the char-based position of the next Unicode code point in the iteration that would be returned by a subsequent call to next, or the end index if the iteration has reached the end.

Since Kotlin 2.5
Link copied to clipboard
abstract fun previous(): CodePoint

Returns the previous code point in the iteration and moves the iteration position backward by one code point.

Since Kotlin 2.5
Link copied to clipboard
abstract fun previousIndex(): Int

Returns the char-based position of the previous Unicode code point in the iteration that would be returned by a subsequent call to previous, or -1 if the iteration has reached the beginning.

Since Kotlin 2.5
Link copied to clipboard

Returns an Iterator that wraps each element produced by the original iterator into an IndexedValue containing the index of that element and the element itself.

Since Kotlin 1.0