Module: text.stringbuilder

Source: ./text/stringbuilder.reef


Overview

text.stringbuilder - Efficient string building

Provides efficient concatenation of many strings by collecting parts and joining them at the end, avoiding O(n^2) repeated concatenation.

Usage: let sb = sb_new() sb_append(sb, "Hello") sb_append(sb, " ") sb_append(sb, "World") let result = sb_build(sb) // "Hello World"


Types

StringBuilder

Fields:

Name Type
parts [string]
part_count int
parts_cap int
total_len int

Functions

fn sb_new(): StringBuilder

fn sb_with_capacity(cap: int): StringBuilder

fn sb_build(sb: StringBuilder): string

fn sb_length(sb: StringBuilder): int

fn sb_part_count(sb: StringBuilder): int


Procedures

proc grow_parts(sb: StringBuilder)

proc sb_append(sb: StringBuilder, s: string)

proc sb_append_char(sb: StringBuilder, c: char)

proc sb_append_int(sb: StringBuilder, n: int)

proc sb_append_line(sb: StringBuilder, s: string)

proc sb_newline(sb: StringBuilder)

proc sb_clear(sb: StringBuilder)


Generated by reefc doc