@utilityjs/disjoint-set
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

DisjointSet

An implementation of DisjointSet data structure.

license npm latest package npm downloads types

npm i @utilityjs/disjoint-set | yarn add @utilityjs/disjoint-set

declare type KeyGenerator<T> = (value: T) => string;

export declare class Item<T> {
  constructor(value: T, keyGenerator?: KeyGenerator<T>);
  getKey(): string;
  getRoot(): Item<T>;
  isRoot(): boolean;
  getRank(): number;
  getChildren(): Item<T>[];
  setParent(parent: Item<T>, alsoAsParentChild?: boolean): void;
  getParent(): Item<T> | null;
  addChild(child: Item<T>): void;
}

export default class DisjointSet<T> {
  constructor(keyGenerator?: KeyGenerator<T>);
  makeSet(value: T): void;
  find(value: T): string | null;
  union(valueA: T, valueB: T): DisjointSet<T>;
  inSameSet(valueA: T, valueB: T): boolean;
}

Package Sidebar

Install

npm i @utilityjs/disjoint-set

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

10.8 kB

Total Files

8

Last publish

Collaborators

  • mimshins