SlotWriter
class SlotWriter
kotlin.Any | |
↳ | androidx.compose.runtime.SlotWriter |
The writer for a slot table. See SlotTable for details.
Summary
Public methods | |
---|---|
Unit |
Advance currentGroup by amount. |
Anchor |
Allocate an anchor to the current group or index. |
Int |
anchorIndex(anchor: Anchor) Return the current anchor location while changing the slot table. |
Unit |
Begin inserting at the current location. |
Unit |
close() Close the writer |
Int |
endGroup() End the current group. |
Unit |
Ends inserting. |
Unit |
ensureStarted(index: 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 index. |
Unit |
ensureStarted(anchor: Anchor) |
Any? |
Return the aux of the group at index. |
Int |
Return the key for the group at index. |
Any? |
groupObjectKey(index: Int) Return the object key for the group at index, if it has one, or null if not. |
Int |
Return the size of the group at index. |
Iterator<Any?> |
Returns an iterator for all the slots of group and all the children of the group. |
String |
A debugging aid that emits groups as a string. |
List<Anchor> |
Move (insert and then delete) the group at index from slots. |
Unit |
Move the group at offset groups after currentGroup to be in front of currentGroup. |
Any? | |
Int |
Return the index of the parent for the group at index. |
Int |
Return the index of the parent for the group referenced by anchor. |
Boolean |
Remove the current group. |
Unit |
Seek the current location to anchor. |
Unit |
Set the value at the groups current data slot |
Any? | |
Any? |
skip() Skip the current slot without updating. |
Int |
Skip the current group. |
Unit |
Skip to the end of the current group. |
Unit |
Start a data group. |
Unit |
Start a data group. |
Unit |
Enter the group at current without changing it. |
Unit |
startGroup(key: Int) Start a group with a integer key |
Unit |
startGroup(key: Int, dataKey: Any?) Start a group with a data key |
Unit |
Start a node. |
Unit |
Start a node |
String |
toString() |
Any? |
Set the value of the next slot. |
Unit |
Updates the data for the current data group. |
Unit |
updateNode(value: Any?) Updates the node for the current node group. |
Unit |
updateParentNode(value: Any?) Updates the node of the parent group. |
Properties | |
---|---|
Boolean |
True if the writer has been closed |
Int |
The current group that will be started by startGroup or skipped by skipGroup |
Boolean |
True if at the end of a group and an endGroup is expected. |
Boolean |
Return true if the current slot starts a node. |
Int |
Return the index of the nearest group that contains currentGroup. |
Public methods
advanceBy
fun advanceBy(amount: Int): Unit
Advance currentGroup by amount. The currentGroup group cannot be advanced outside the currently started parent.
anchor
fun anchor(index: Int = currentGroup): Anchor
Allocate an anchor to the current group or index.
anchorIndex
fun anchorIndex(anchor: Anchor): Int
Return the current anchor location while changing the slot table.
beginInsert
fun beginInsert(): Unit
Begin inserting at the current location. beginInsert() can be nested and must be called with a balanced number of endInsert()
endGroup
fun endGroup(): Int
End the current group. Must be called after the corresponding startGroup().
ensureStarted
fun ensureStarted(index: 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 index. If, after starting, the group, currentGroup is not a the end of the group or currentGroup is not at the start of a group for which index 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.
groupObjectKey
fun groupObjectKey(index: Int): Any?
Return the object key for the group at index, if it has one, or null if not.
groupSlots
fun groupSlots(): Iterator<Any?>
Returns an iterator for all the slots of group and all the children of the group.
moveFrom
fun moveFrom(
table: SlotTable,
index: Int
): List<Anchor>
Move (insert and then delete) the group at index from slots. All anchors in the range (including index) 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 group at offset groups after currentGroup to be in front of currentGroup. After this completes, the moved group will be the current group. offset must less than the number of groups after the currentGroup left in the parent group.
parent
fun parent(anchor: Anchor): Int
Return the index of the parent for the group referenced by anchor. If the anchor is not valid it returns -1.
removeGroup
fun removeGroup(): Boolean
Remove the current group. Returns if any anchors were in the group removed.
seek
fun seek(anchor: Anchor): Unit
Seek the current location to anchor. The anchor must be an anchor to a possibly indirect child of parent.
set
fun set(
index: Int,
value: Any?
): Any?
Set the group's slot at index to value. Returns the previous value.
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.
skipGroup
fun skipGroup(): Int
Skip the current group. Returns the number of nodes skipped by skipping the group.
startGroup
fun startGroup(): Unit
Enter the group at current without changing it. Requires not currently inserting.
toString
fun toString(): String
update
fun update(value: Any?): Any?
Set the value of the next slot. Returns the previous value of the slot or EMPTY is being inserted.
Properties
currentGroup
var currentGroup: Int
The current group that will be started by startGroup or skipped by skipGroup
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.