Google is committed to advancing racial equity for Black communities. See how.

SlotWriter

class SlotWriter
kotlin.Any
   ↳ androidx.compose.SlotWriter

Summary

Public methods
Anchor
anchor(index: Int = current)

Allocate an anchor for a location.

Unit

Begin inserting at the current location.

Unit

Int

End a data node

Int

End the current group.

Unit

Ends inserting.

Int

End a node

Unit
ensureStarted(location: Int)

If the start of a group was skipped using skip, calling ensureStarted puts the writer into the same state as if startGroup or startNode was called on the group starting at location.

Unit

Any?
get(anchor: Anchor)

Get the value at an Anchor

Any?
get(index: Int)

Get the value at the index'th slot.

Int
groupSize(index: Int)

Return the size of the group at index.

Iterator<Any?>

Returns an iterator for the slots of group.

Boolean
isGroup(index: Int)

Return true if the slot at index starts a gorup

List<Anchor>
moveFrom(table: SlotTable, location: Int)

Move (insert and then delete) the group at location from slots.

Unit
moveGroup(offset: Int)

Move the offset'th group after the current group to the current location.

Int

Return the start location of the nearest group that contains the slot at anchor.

Boolean

Remove a group.

Unit
set(value: Any?)

Set the value at the slot previous to current.

Any?

Skip the current slot without updating.

Unit
skip(amount: Int)

Skip amount slots in the slot table.

Int

Skip a group.

Int

Skip a node

Unit

Skip to the end of the current group.

Unit
startData(key: Int, dataKey: Any?, data: Any?)

Start a data node.

Unit

Enter the group at current without changing it.

Unit

Start a group with a integer key

Unit
startGroup(key: Int, dataKey: Any?)

Start a group with a data key

Unit

Enter an existing node

Unit
startNode(key: Any?)

Start a node.

Unit
startNode(key: Any?, node: Any?)

Start a node

String

Any?
update(value: Any?)

Set the value of the next slot.

Unit
updateData(value: Any?)

Updates the data for a data group

Properties
Boolean

True if the writer has been closed

Int

Int

Return the number of nodes in the group.

Boolean

Return true if the current slot starts a group

Boolean

Return true if the current slot starts a node.

Int

Get the number of nodes emitted to the group prior to the current slot.

Int

Return the start location of the nearest group that contains current.

Int

Get the total number of nodes emitted in the group containing the current.

SlotTable

Public methods

anchor

fun anchor(index: Int = current): Anchor

Allocate an anchor for a location. As content is inserted and removed from the slot table the anchor is updated to reflect those changes. For example, if an anchor is requested for an group, the anchor will report the location of that group even if the group is moved in the slot table. If the position referenced by the anchor is removed, the anchor location is set to -1.

beginInsert

fun beginInsert(): Unit

Begin inserting at the current location. beginInsert() can be nested and must be called with a balanced number of endInsert()

close

fun close(): Unit

endData

fun endData(): Int

End a data node

endGroup

fun endGroup(): Int

End the current group. Must be called after the corresponding startGroup().

endInsert

fun endInsert(): Unit

Ends inserting.

endNode

fun endNode(): Int

End a node

ensureStarted

fun ensureStarted(location: Int): Unit

If the start of a group was skipped using skip, calling ensureStarted puts the writer into the same state as if startGroup or startNode was called on the group starting at location. If, after starting, the group, current is not a the end of the group or current is not at the start of a group for which location is not location the parent group, an exception is thrown.

Calling ensureStarted implies that an endGroup should be called once the end of the group is reached.

ensureStarted

fun ensureStarted(anchor: Anchor): Unit

get

fun get(anchor: Anchor): Any?

Get the value at an Anchor

get

fun get(index: Int): Any?

Get the value at the index'th slot.

groupSize

fun groupSize(index: Int): Int

Return the size of the group at index. isGroup(index) must be true of this will throw.

groupSlots

fun groupSlots(): Iterator<Any?>

Returns an iterator for the slots of group.

isGroup

fun isGroup(index: Int): Boolean

Return true if the slot at index starts a gorup

moveFrom

fun moveFrom(
    table: SlotTable,
    location: Int
): List<Anchor>

Move (insert and then delete) the group at location from slots. All anchors in the range (including location) are moved to the slot table for which this is a reader.

It is required that the writer be inserting.

Return
a list of the anchors that were moved

moveGroup

fun moveGroup(offset: Int): Unit

Move the offset'th group after the current group to the current location.

parentIndex

fun parentIndex(anchor: Anchor): Int

Return the start location of the nearest group that contains the slot at anchor.

removeGroup

fun removeGroup(): Boolean

Remove a group. Must be called at group.

set

fun set(value: Any?): Unit

Set the value at the slot previous to current.

skip

fun skip(): Any?

Skip the current slot without updating. If the slot table is inserting then and EMPTY slot is added and skip return EMPTY.

skip

fun skip(amount: Int): Unit

Skip amount slots in the slot table. If the slot table is inserting then this adds amount slots.

Skip cannot skip outside the current group.

skipGroup

fun skipGroup(): Int

Skip a group. Must be called at the start of a group.

skipNode

fun skipNode(): Int

Skip a node

skipToGroupEnd

fun skipToGroupEnd(): Unit

Skip to the end of the current group.

startData

fun startData(
    key: Int,
    dataKey: Any?,
    data: Any?
): Unit

Start a data node.

startGroup

fun startGroup(): Unit

Enter the group at current without changing it. Requires not currently inserting.

startGroup

fun startGroup(key: Int): Unit

Start a group with a integer key

startGroup

fun startGroup(
    key: Int,
    dataKey: Any?
): Unit

Start a group with a data key

startNode

fun startNode(): Unit

Enter an existing node

startNode

fun startNode(key: Any?): Unit

Start a node.

startNode

fun startNode(
    key: Any?,
    node: Any?
): Unit

Start a node

toString

fun toString(): String

update

fun update(value: Any?): Any?

Set the value of the next slot.

updateData

fun updateData(value: Any?): Unit

Updates the data for a data group

Properties

closed

var closed: Boolean

True if the writer has been closed

current

var current: Int

groupSize

val groupSize: Int

Return the number of nodes in the group. isGroup must be true or this will throw.

isGroup

val isGroup: Boolean

Return true if the current slot starts a group

isNode

val isNode: Boolean

Return true if the current slot starts a node. A node is a kind of group so this will return true for isGroup as well.

nodeIndex

val nodeIndex: Int

Get the number of nodes emitted to the group prior to the current slot.

parentLocation

val parentLocation: Int

Return the start location of the nearest group that contains current.

parentNodes

val parentNodes: Int

Get the total number of nodes emitted in the group containing the current.

table

val table: SlotTable