android-components / mozilla.components.browser.engine.system.matcher / ReversibleString

ReversibleString

abstract class ReversibleString (source)

A String wrapper utility that allows for efficient string reversal. We regularly need to reverse strings. The standard way of doing this in Java would be to copy the string to reverse (e.g. using StringBuffer.reverse()). This seems wasteful when we only read our Strings character by character, in which case can just transpose positions as needed.

Properties

isReversed

abstract val isReversed: Boolean

offsetEnd

val offsetEnd: Int

offsetStart

val offsetStart: Int

string

val string: String

Functions

charAt

abstract fun charAt(position: Int): Char

length

fun length(): Int

Returns the length of this string.

reverse

fun reverse(): ReversibleString

Reverses this string.

substring

abstract fun substring(startIndex: Int): ReversibleString

Companion Object Functions

create

fun create(string: String): ReversibleString

Create a ReversibleString for the provided String.