SlotMap

interface SlotMap : Iterable<Slot>

The property table behind a ScriptableObject. It is iterable but is not a Map, because a real map brings overhead this does not need.

The shape of this interface is odd and its dealings with ScriptableObject are involved. Upstream says plainly that tidier versions of it cost real performance, so it stays as it is.

Inheritors

Types

Link copied to clipboard
fun interface SlotComputer<S : Slot>

Decides what a key maps to, given whatever is already there. Returning null removes it.

Functions

Link copied to clipboard
abstract fun add(owner: SlotMapOwner?, newSlot: Slot)

Puts a slot straight in. Both its name and its index hash have to be set already. ScriptableObject normally goes through modify instead.

Link copied to clipboard
open fun <S : Slot> compute(owner: SlotMapOwner, key: Any?, index: Int, compute: SlotMap.SlotComputer<S>): S?

Replaces what key maps to with whatever compute returns: null removes the mapping, and anything else replaces or creates it. If compute throws, nothing changes.

abstract fun <S : Slot> compute(owner: SlotMapOwner?, mutableMap: CompoundOperationMap, key: Any?, index: Int, compute: SlotMap.SlotComputer<S>): S?
Link copied to clipboard
open fun dirtySize(): Int

The size before any pending compound operation is folded back in.

Link copied to clipboard
abstract fun isEmpty(): Boolean

Whether there are no slots at all.

Link copied to clipboard
abstract operator fun iterator(): Iterator<Slot>
Link copied to clipboard
abstract fun modify(owner: SlotMapOwner?, key: Any?, index: Int, attributes: Int): Slot

The slot for key, or for index when key is null, creating one if it is not there yet.

Link copied to clipboard
abstract fun query(key: Any?, index: Int): Slot?

The slot for key, or for index when key is null, or null if there is none.

Link copied to clipboard
abstract fun size(): Int

How many slots there are.

Link copied to clipboard

Opens a compound operation over this map.