The second Android 11 Developer Preview is now available, test it out and share your feedback.

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 the current group.

Unit

Ends inserting.

Int

End a node

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

Unit
moveGroup(offset: Int)

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

Unit

Backup one slot.

Boolean

Remove a group.

Unit
set(value: Any?)

Set the value at the current slot.

Any?

Skip the current slot without updating

Int

Skip a group.

Int

Skip a node

Unit

Start a group.

Unit
startNode(key: Any)

Start a node.

String

Any?
update(value: Any?)

Set the value of the next slot.

Properties

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

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

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

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

moveGroup

fun moveGroup(offset: Int): Unit

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

previous

fun previous(): Unit

Backup one slot. For example, we ran into a key of a keyed group we don't want, this backs up current to be before the key.

removeGroup

fun removeGroup(): Boolean

Remove a group. Must be called at group.

set

fun set(value: Any?): Unit

Set the value at the current slot.

skip

fun skip(): Any?

Skip the current slot without updating

skipGroup

fun skipGroup(): Int

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

skipNode

fun skipNode(): Int

Skip a node

startGroup

fun startGroup(key: Any): Unit

Start a group.

Parameters
key: Any The group key. Passing EMPTY will retain as was written last time. An EMPTY key is not valid when inserting groups.

startNode

fun startNode(key: Any): Unit

Start a node.

toString

fun toString(): String

update

fun update(value: Any?): Any?

Set the value of the next slot.

Properties

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.

parentIndex

val parentIndex: Int

parentNodes

val parentNodes: Int

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

table

val table: SlotTable