Skip to content

Defined in: packages/disjoint-set/src/indexed-disjoint-set.ts:8

A dense integer disjoint set that can append the next index.

readonly size: number

Defined in: packages/disjoint-set/src/disjoint-set.ts:55

Number of elements across all sets. O(1).

DisjointSet.size


readonly setCount: number

Defined in: packages/disjoint-set/src/disjoint-set.ts:57

Number of disjoint sets. O(1).

DisjointSet.setCount


readonly has: (element) => boolean

Defined in: packages/disjoint-set/src/disjoint-set.ts:59

Return true when the element belongs to the disjoint set. O(1) average.

number

boolean

DisjointSet.has


readonly unite: (x, y) => boolean

Defined in: packages/disjoint-set/src/disjoint-set.ts:67

Merge the sets containing x and y. O(alpha(n)) amortized.

number

number

boolean

true when two distinct sets were merged, false when both elements already belonged to the same set.

When either element is absent.

DisjointSet.unite


readonly areConnected: (x, y) => boolean

Defined in: packages/disjoint-set/src/disjoint-set.ts:74

Return true when x and y belong to the same set. O(alpha(n)) amortized.

number

number

boolean

When either element is absent.

DisjointSet.areConnected


readonly find: (element) => number

Defined in: packages/disjoint-set/src/disjoint-set.ts:81

Return the representative of the set containing the element. O(alpha(n)) amortized.

number

number

When the element is absent.

DisjointSet.find


readonly elements: () => IterableIterator<number>

Defined in: packages/disjoint-set/src/disjoint-set.ts:88

Iterate over every element in insertion order. O(1) per step, O(n) total.

The iterator covers the elements present when the call was made, so adding elements while iterating does not extend the walk.

IterableIterator<number>

DisjointSet.elements


readonly sets: () => Map<number, number[]>

Defined in: packages/disjoint-set/src/disjoint-set.ts:94

Collect every set into a Map keyed by representative. Members appear in insertion order. O(n * alpha(n)) time and O(n) space. The result is a copy and does not track later mutations.

Map<number, number[]>

DisjointSet.sets


readonly kind: "indexed"

Defined in: packages/disjoint-set/src/indexed-disjoint-set.ts:9

Stable identifier for the implementation’s storage layout.

DisjointSet.kind


readonly append: () => number

Defined in: packages/disjoint-set/src/indexed-disjoint-set.ts:11

Append and return the next dense index. O(1) amortized.

number