KStateContainer
The StateContainer implementation for Kotlin components. Tracks all state defined by useState calls for the same component (see KState for usage). Immutable by default: every copy-on-write mutation returns a new instance with the prior entries copied and one entry added or replaced. The one exception is the transient render-owned fork (mutableForkWith / mutateInPlace): a render forks a single mutable copy of its component's container and then mutates that copy in place for the rest of the pass, tracked by ComponentScope.ownedStateContainer. Committed/shared containers are never mutated in place - a subsequent render forks them.
Each entry carries its HookKey; lookup is an O(N) linear scan over the list using HookKey equality via getByHookKey/hasHookKey/copyAndMutateByHookKey. Interning lets equality short-circuit on reference identity, so the scan is essentially a pointer compare.
Functions
Add or replace the entry for hookKey, preserving its existing CachedValue.deps when one is already present (and using NoDeps otherwise).
Fork a single mutable copy of this container with hookKey added or replaced. The returned container's backing is a live ArrayList (not wrapped), so the owning render can keep mutating it in place via mutateInPlace for the rest of the pass. The caller (KState) records the result as ComponentScope.ownedStateContainer so subsequent mutations this pass route to mutateInPlace.
Mutate this container in place. MUST ONLY be done by a scope that owns this container for its current render pass (tracked by ComponentScope.ownedStateContainer); the caller guarantees that with an identity check.
Return a container with only the entries whose CachedValue.hookKey is in live (null-hookKey index entries are always kept). Returns this when nothing is dropped.