CharBuffer

port of java.nio.CharBuffer

A very simple, mutable (or optionally read-only) character buffer.

This class mimics basic behaviors of a CharBuffer:

  • Relative get() and put() operations that update the current position.

  • Absolute get/put via helper methods.

  • Bulk get/put.

  • Slicing, duplicating, compacting, and creating a read-only view.

  • Implements CharSequence (the sequence being the “remaining” characters, i.e. from the current position up to the limit) and Appendable.

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
Link copied to clipboard
open override val length: Int
Link copied to clipboard
var limit: Int
Link copied to clipboard
var mark: Int
Link copied to clipboard

Functions

Link copied to clipboard
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
Link copied to clipboard
Link copied to clipboard

Returns a read-only view of this buffer.

Link copied to clipboard

Clears the buffer: position ← 0, limit ← capacity, mark undefined.

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

Compacts the buffer by moving the remaining characters to the beginning.

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

Lexicographically compares the remaining characters of this buffer to another buffer's remaining characters.

Link copied to clipboard

Duplicates the buffer, sharing the underlying array and preserving the state.

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard

Flips the buffer: limit ← current position, position ← 0, mark undefined.

Link copied to clipboard
fun get(): Char

Relative get: reads the char at current position and increments position.

open operator override fun get(index: Int): Char

fun get(dst: CharArray, dstOffset: Int, length: Int): CharBuffer

Reads length characters into dst starting at dstOffset, advancing the buffer’s position.

Link copied to clipboard
fun getAbsolute(index: Int): Char

Absolute get: returns the char at the given index (0 ≤ index < limit) without changing position.

Link copied to clipboard
Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard

Tells whether there are any elements between the current position and the limit.

Link copied to clipboard
Link copied to clipboard

Sets the mark at the current position. After this call, calling reset() will return the position to here.

Link copied to clipboard
fun position(): Int
Link copied to clipboard

Relative put: writes the char at current position and increments position.

fun put(src: String): CharBuffer
fun put(src: String, start: Int, end: Int): CharBuffer

Relative bulk put method  (optional operation).

fun put(src: CharArray, srcOffset: Int, length: Int): CharBuffer

Writes length characters from src (starting at srcOffset) into this buffer, advancing the position.

Link copied to clipboard
fun putAbsolute(index: Int, c: Char): CharBuffer

Absolute put: writes the char at the given index (0 ≤ index < limit) without changing position.

Link copied to clipboard
fun putBuffer(pos: Int, src: CharBuffer, srcPos: Int, n: Int)
Link copied to clipboard
fun remaining(): Int

Returns the number of characters between position and limit.

Link copied to clipboard

Resets the position to the last mark. Throws IllegalStateException if no mark has been set.

Link copied to clipboard

Slices the buffer, creating a new buffer that shares the underlying array and represents the remaining characters (from current position to limit).

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