Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Builder ¶
type Builder[T any] struct { // contains filtered or unexported fields }
Builder is a struct that builds a tree.
func (*Builder[T]) Build ¶
MakeTree creates a tree from the given element.
Parameters:
- elem: The element to start the tree from.
- info: The info of the element.
- f: The function that, given an element and info, returns the next elements. (i.e., the children of the element).
Returns:
- *Tree[T]: The tree created from the element.
- error: An error if the tree cannot be created.
Behaviors:
- The 'info' parameter is copied for each node and it specifies the initial info before traversing the tree.
func (*Builder[T]) SetInfo ¶
SetInfo sets the info of the builder.
Parameters:
- info: The info to set.
func (*Builder[T]) SetNextFunc ¶
SetNextFunc sets the next function of the builder.
Parameters:
- f: The function to set.
type NextsFunc ¶
NextsFunc is a function that returns the next elements.
Parameters:
- elem: The element to get the next elements from.
- info: The info of the element.
Returns:
- []T: A slice of the next elements.
- error: An error if the function fails.
type ObserverFunc ¶
ObserverFunc is a function that observes a node.
Parameters:
- data: The data of the node.
- info: The info of the node.
Returns:
- bool: True if the traversal should continue, otherwise false.
- error: An error if the observation fails.
Click to show internal directories.
Click to hide internal directories.