StringBuffer

A simplified, mutable sequence of characters similar in spirit to Java’s StringBuffer.

Note: This implementation is not truly thread‑safe.

Constructors

Link copied to clipboard
constructor()

Constructs a StringBuffer with an initial capacity of 16 characters. (The capacity is not actually enforced in this simple version.)

constructor(capacity: Int)

Constructs a StringBuffer with the specified initial capacity. The capacity parameter is advisory only.

constructor(str: String)

Constructs a StringBuffer initialized to the contents of the given string.

constructor(seq: CharSequence)

Constructs a StringBuffer that contains the same characters as the specified CharSequence.

Properties

Link copied to clipboard
open override val length: Int

Functions

Link copied to clipboard
fun append(obj: Any?): StringBuffer

Appends the string representation of the obj to this buffer.

open override fun append(c: Char): Appendable
open override fun append(csq: CharSequence?): Appendable
open override fun append(csq: CharSequence?, start: Int, end: Int): Appendable
Link copied to clipboard

Returns the Unicode code point at the specified index of this CharSequence.

Link copied to clipboard

Returns a stream of code point values from this sequence. Any surrogate pairs encountered in the sequence are combined as if by {@linkplain Character#toCodePoint Character.toCodePoint} and the result is passed to the stream. Any other code units, including ordinary BMP characters, unpaired surrogates, and undefined code units, are zero-extended to {@code int} values which are then passed to the stream.

Link copied to clipboard
open operator override fun compareTo(other: StringBuffer): Int

Compares this StringBuffer with another lexicographically.

Link copied to clipboard
open operator override fun get(index: Int): Char
Link copied to clipboard
fun getChars(srcBegin: Int, srcEnd: Int, dst: CharArray, dstBegin: Int)
Link copied to clipboard
fun insert(index: Int, str: String): StringBuffer

Inserts the string str at the specified index.

Link copied to clipboard
fun setCharAt(index: Int, ch: Char)

Sets the character at the specified index to ch.

Link copied to clipboard
open override fun subSequence(startIndex: Int, endIndex: Int): CharSequence
Link copied to clipboard
open override fun toString(): String

Returns the current string representation.