shadow:standard

Class MutableString

Parent class

shadow:standard@Object

Interfaces

shadow:standard@CanIndex<long,ubyte>, shadow:standard@CanIndexStore<long,ubyte>, shadow:standard@CanCompare<shadow:standard@MutableString>, shadow:standard@CanHash

locked class MutableString

Class MutableString holds arbitrary-length sequences of UTF-8 code points stored in a dynamic array of ubyte values. MutableString objects differ from String objects in that their contents can be changed.

See Also

Create Summary

Modifiers Return Types Method and Description
public () create()

Creates a new MutableString with no code points and the capacity to hold 10 bytes worth of code points.

public () create(long capacity)

Creates a new MutableString with no code points and the capacity to hold the specified number of bytes worth of code points.

public () create(nullable Object initialValue)

Creates a new MutableString containing the string representation of an object.

Destroy Summary

Modifiers Return Types Method and Description
public () destroy()

Method Summary

Modifiers Return Types Method and Description
public locked (MutableString) append(nullable Object value)

Appends a String representation of the given value to the end of the string representation.

public locked (MutableString) append(ubyte value)

Appends a single ubyte value to the end of the string representation.

public readonly locked (int) compare(MutableString other)

Compares the current object to another MutableString, returning -1, 0, or 1, if the current object comes earlier, at exactly the same point, or later in a lexicographic ordering than the other value, respectively.

public readonly (MutableString) copy(AddressMap addresses)
public locked (MutableString) delete(long index)

Deletes the byte value at the given offset, shortening the string representation by one byte.

public locked (MutableString) delete(long start, long end)

Deletes all the byte values from the starting offset up to but not including the ending offset, shortening the string representation by end - start bytes.

public locked (MutableString) ensureCapacity(long size)

Guarantees that there is enough space in the MutableString to hold the specified number of bytes.

public readonly locked (boolean) equal(MutableString other)

Compares the current object to another MutableString, returning true if they are identical.

public readonly locked (ubyte) index(long index)

Retrieves the ubyte value at the given offset inside the object.

public locked () index(long index, ubyte value)

Stores the given ubyte value at the given offset inside the object.

public locked (MutableString) insert(long index, nullable Object value)

Inserts a String representation of the given value at the given offset inside the object, moving over any values coming after the offset

public locked (MutableString) insert(long index, ubyte value)

Inserts the given ubyte value at the given offset inside the object, moving over any values coming after the offset

public locked (MutableString) prepend(nullable Object value)

Prepends a String representation of the given value to the beginning of the string representation, moving all other values down.

public locked (MutableString) prepend(ubyte value)

Prepends a single ubyte value to the beginning of the string representation, moving all other values down.

public locked (MutableString) reverse()

Reverses the order of the ubyte values stored in this string representation.

public readonly locked (String) substring(long start, long end)

Produces a substring of this string representation, from the starting byte offset up to but not including the ending byte offset.

public readonly locked (String) toString()

Produces an immutable String version of this string representation.

Property Summary

Modifiers Return Types Method and Description
public readonly get locked (long) capacity()

Retrieves the current capacity of the MutableString in bytes.

public get locked (ulong) hash()

Finds a hash value for the current object.

public get locked (int) size()

Gets the number of ubyte values stored as part of the string as an int.

public readonly get locked (long) sizeLong()

Number of ubyte values stored as part of the string.

Create Detail

create

public create() => ()

Creates a new MutableString with no code points and the capacity to hold 10 bytes worth of code points.

create

public create(long capacity) => ()

Creates a new MutableString with no code points and the capacity to hold the specified number of bytes worth of code points.

Parameters

capacity - initial storage capacity in bytes

create

public create(nullable Object initialValue) => ()

Creates a new MutableString containing the string representation of an object.

Parameters

initialValue - object whose string representation will fill the new MutableString

Destroy Detail

destroy

public destroy() => ()

Method Detail

append

public locked append(nullable Object value) => (MutableString)

Appends a String representation of the given value to the end of the string representation.

Parameters

value - value to append

Returns

MutableString object after append

append

public locked append(ubyte value) => (MutableString)

Appends a single ubyte value to the end of the string representation.

Parameters

value - value to append

Returns

MutableString object after append

compare

public readonly locked compare(MutableString other) => (int)

Compares the current object to another MutableString, returning -1, 0, or 1, if the current object comes earlier, at exactly the same point, or later in a lexicographic ordering than the other value, respectively.

Parameters

other - value to compare to

Returns

whether earlier, identical, or later

copy

public readonly copy(AddressMap addresses) => (MutableString)

delete

public locked delete(long index) => (MutableString)

Deletes the byte value at the given offset, shortening the string representation by one byte.

Parameters

index - offset inside the object

Returns

MutableString object after deletion

Throws

IndexOutOfBoundsException - if the offset is illegal

delete

public locked delete(long start, long end) => (MutableString)

Deletes all the byte values from the starting offset up to but not including the ending offset, shortening the string representation by end - start bytes.

Parameters

start - starting offset

end - ending offset

Returns

MutableString object after deletion

Throws

IllegalArgumentException - if either of the offsets is illegal

ensureCapacity

public locked ensureCapacity(long size) => (MutableString)

Guarantees that there is enough space in the MutableString to hold the specified number of bytes. If there is insufficient space, this method will take the larger of the requested size and twice the current capacity, to avoid repeated resizes for a series of single byte additions.

Parameters

size - minimize number of bytes the MutableString must be able to hold

Returns

current MutableString object, possibly resized

equal

public readonly locked equal(MutableString other) => (boolean)

Compares the current object to another MutableString, returning true if they are identical.

Parameters

other - object to compare to

Returns

true if identical

index

public readonly locked index(long index) => (ubyte)

Retrieves the ubyte value at the given offset inside the object.

Parameters

index - offset inside the object

Returns

ubyte value

Throws

IndexOutOfBoundsException - if the offset is illegal

index

public locked index(long index, ubyte value) => ()

Stores the given ubyte value at the given offset inside the object.

Parameters

index - offset inside the object

value - value to store

Throws

IndexOutOfBoundsException - if the offset is illegal

insert

public locked insert(long index, nullable Object value) => (MutableString)

Inserts a String representation of the given value at the given offset inside the object, moving over any values coming after the offset

Parameters

index - offset inside the object

value - value to store

Returns

MutableString object after insertion

Throws

IndexOutOfBoundsException - if the offset is illegal

insert

public locked insert(long index, ubyte value) => (MutableString)

Inserts the given ubyte value at the given offset inside the object, moving over any values coming after the offset

Parameters

index - offset inside the object

value - value to store

Throws

IndexOutOfBoundsException - if the offset is illegal

prepend

public locked prepend(nullable Object value) => (MutableString)

Prepends a String representation of the given value to the beginning of the string representation, moving all other values down.

Parameters

value - value to append

Returns

MutableString object after append

prepend

public locked prepend(ubyte value) => (MutableString)

Prepends a single ubyte value to the beginning of the string representation, moving all other values down.

Parameters

value - value to prepend

Returns

MutableString object after prepend

reverse

public locked reverse() => (MutableString)

Reverses the order of the ubyte values stored in this string representation. Note that this method may not correctly reverse representations containing multi-byte code points.

Returns

reversed MutableString object

substring

public readonly locked substring(long start, long end) => (String)

Produces a substring of this string representation, from the starting byte offset up to but not including the ending byte offset.

Parameters

start - starting offset

end - ending offset

Returns

substring

Throws

IllegalArgumentException - if either of the offsets is illegal

toString

public readonly locked toString() => (String)

Produces an immutable String version of this string representation.

Returns

immutable String version

Property Detail

capacity

public readonly get locked capacity() => (long)

Retrieves the current capacity of the MutableString in bytes.

Returns

current capacity in bytes

hash

public get locked hash() => (ulong)

Finds a hash value for the current object.

Returns

hash value

size

public get locked size() => (int)

Gets the number of ubyte values stored as part of the string as an int.

Returns

number of bytes

sizeLong

public readonly get locked sizeLong() => (long)

Number of ubyte values stored as part of the string.