Skip to content

Defined in: packages/disjoint-set/src/serialization/json.ts:28

A plain, inert description of a partition. It holds no behavior and no reference to the structure it came from, so it can be stored, compared, structurally cloned, or sent through postMessage. It survives JSON.stringify when the elements themselves do.

kind identifies the storage layout to restore. The two arrays are parallel and always have the same length. labels[i] is the group of elements[i]. Labels are opaque. Two elements share a set when their labels are equal, and nothing else about the value is meaningful. serializeDisjointSetJson emits dense labels counting from 0, and deserializeDisjointSetJson accepts any numbers and groups them by equality.

T

readonly schemaVersion: 1

Defined in: packages/disjoint-set/src/serialization/json.ts:30

Wire-schema version.


readonly kind: "object" | "struct-of-arrays"

Defined in: packages/disjoint-set/src/serialization/json.ts:32

The storage layout to restore when no factory override is supplied.


readonly elements: readonly T[]

Defined in: packages/disjoint-set/src/serialization/json.ts:34

Every element, in the order it was added.


readonly labels: readonly number[]

Defined in: packages/disjoint-set/src/serialization/json.ts:36

The group label of the element at the same position.