type
constructors
make |
Create with initial capacity (defaults to 16). |
---|
fields
capacity |
The number of characters this buffer can hold without allocating more memory. |
---|
methods
add |
Add x.toStr to the end of this buffer. |
---|---|
addChar |
Optimized implementation for add(ch.toChar). |
clear |
Clear the contents of the string buffer so that is has a size of zero. |
get |
Get the character at the zero based index as a Unicode code point. |
getRange |
Return a substring based on the specified range. |
insert |
Insert x.toStr into this buffer at the specified index. |
isEmpty |
Return if size() == 0. |
join |
Add x.toStr to the end of the buffer. |
out |
Create an output stream to append characters to this string buffer. |
remove |
Remove the char at the specified index. |
removeRange |
Remove a range of indices from this buffer. |
replaceRange |
Replaces a range of indices from this buffer with the specified string. |
reverse |
Reverse the contents of this string buffer. |
set |
Replace the existing character at index in this buffer. |
size |
Return the number of characters in the buffer. |
toStr |
Return the current buffer contents as a Str. |
Slot Details
add
addChar
capacity
Int capacity
The number of characters this buffer can hold without allocating more memory.
clear
This clear()
Clear the contents of the string buffer so that is has a size of zero. Return this.
get
getRange
@Operator
Str getRange(Range range)
Return a substring based on the specified range. Negative indexes may be used to access from the end of the string buffer. This method is accessed via the [] operator. Throw IndexErr if range illegal.
Examples:
"abcd"[0..2] => "abc" "abcd"[3..3] => "d" "abcd"[-2..-1] => "cd" "abcd"[0..<2] => "ab" "abcd"[1..-2] => "bc" "abcd"[4..-1] => ""
insert
isEmpty
Bool isEmpty()
Return if size() == 0.
join
make
new make(Int capacity := 16)
Create with initial capacity (defaults to 16).
out
OutStream out()
Create an output stream to append characters to this string buffer. The output stream is designed to write character data, attempts to do binary writes will throw UnsupportedErr.
remove
removeRange
replaceRange
reverse
This reverse()
Reverse the contents of this string buffer. Return this.
set
size
Int size()
Return the number of characters in the buffer.
toStr
virtual override Str toStr()
Return the current buffer contents as a Str.