TextElementSequence

Contract for a specialized sequence of TextElements with enhanced search and modification capabilities for lexical preservation operations.

Unlike standard List, this interface provides:

  • Index-based search with predicates (findFirst, findLast, findNext, findPrevious)
  • Element-based search (indexOf, lastIndexOf with overloads)
  • Controlled mutations (insert, remove) where caller manages index adjustments

Thread safety: Implementations are not required to be thread-safe.

Index management: Mutation operations modify the underlying list directly. Callers are responsible for tracking index changes after mutations.

Since

3.28.0

Inheritors

Functions

Link copied to clipboard
abstract fun allMatch(predicate: Predicate<TextElement>): Boolean
Tests whether all elements in this sequence match the given predicate.
Link copied to clipboard
abstract fun anyMatch(predicate: Predicate<TextElement>): Boolean
Tests whether any element in this sequence matches the given predicate.
Link copied to clipboard
abstract fun findFirst(predicate: Predicate<TextElement>): Int
Finds the first index where the predicate matches, searching forward from index 0.
Link copied to clipboard
abstract fun findLast(predicate: Predicate<TextElement>): Int
Finds the last index where the predicate matches, searching backward from the end.
Link copied to clipboard
abstract fun findNext(fromIndex: Int, predicate: Predicate<TextElement>): Int
Finds the next index where the predicate matches, searching forward from fromIndex (inclusive).
Link copied to clipboard
abstract fun findPrevious(fromIndex: Int, predicate: Predicate<TextElement>): Int
Finds the previous index where the predicate matches, searching backward from fromIndex (inclusive).
Link copied to clipboard
abstract fun get(index: Int): TextElement
Returns the element at the specified index.
Link copied to clipboard
open fun indexOf(element: TextElement): Int
Finds the first occurrence of the specified element.
open fun indexOf(fromIndex: Int, element: TextElement): Int
Finds the next occurrence of element starting from fromIndex (inclusive).
Link copied to clipboard
abstract fun insert(index: Int, element: TextElement)
Inserts element at the specified index.
Link copied to clipboard
abstract fun insertAll(index: Int, elements: List<TextElement>)
Inserts all elements at the specified index.
Link copied to clipboard
abstract fun isEmpty(): Boolean
Checks if this sequence is empty.
Link copied to clipboard
abstract fun isValidIndex(index: Int): Boolean
Checks if the index is valid (0 <= index
Link copied to clipboard
Returns an iterator starting at index 0.
abstract fun iterator(fromIndex: Int): TextElementIterator
Returns an iterator starting at the specified index.
Link copied to clipboard
open fun lastIndexOf(element: TextElement): Int
Finds the last occurrence of the specified element.
open fun lastIndexOf(fromIndex: Int, element: TextElement): Int
Finds the previous occurrence of element before fromIndex (inclusive).
Link copied to clipboard
abstract fun noneMatch(predicate: Predicate<TextElement>): Boolean
Tests whether no elements in this sequence match the given predicate.
Link copied to clipboard
abstract fun remove(index: Int)
Removes the element at the specified index.
Link copied to clipboard
abstract fun removeRange(fromIndex: Int, toIndex: Int)
Removes elements in range [fromIndex, toIndex] (inclusive on both ends).
Link copied to clipboard
abstract fun size(): Int
Returns the number of elements in this sequence.
Link copied to clipboard
Returns a stream of elements for functional operations.
Link copied to clipboard
abstract fun subList(fromIndex: Int, toIndex: Int): List<TextElement>
Returns a sublist view [fromIndex, toIndex).
Link copied to clipboard
abstract fun takeWhile(predicate: Predicate<TextElement>): List<TextElement>
Returns a new list containing elements from the start until the predicate fails.
Link copied to clipboard
abstract fun toList(): List<TextElement>
Returns an unmodifiable view of the underlying list.
Link copied to clipboard
abstract fun toMutableList(): List<TextElement>
Returns the underlying mutable list.