Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Build ¶
Build converts a flat slice of nodes into a tree structure using the provided adapter. Time complexity: O(n), Space complexity: O(n).
Types ¶
type Adapter ¶
type Adapter[T any] struct { GetId func(T) string // extracts the unique identifier GetParentId func(T) string // extracts the parent identifier GetChildren func(T) []T // extracts the children slice SetChildren func(*T, []T) // sets the children slice (requires pointer) }
Adapter defines the adapter for building trees from arbitrary data.
Click to show internal directories.
Click to hide internal directories.