TreeExplorer

package
v0.3.38 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 13, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FilterCompleteTokens added in v0.3.26

func FilterCompleteTokens[O any](h []uc.Pair[EvalStatus, O]) bool

FilterCompleteTokens is a filter that filters complete helper tokens.

Parameters:

  • h: The helper tokens to filter.

Returns:

  • bool: True if the helper tokens are incomplete, false otherwise.

func FilterErrorLeaves

func FilterErrorLeaves[O any](h uc.Pair[EvalStatus, O]) bool

FilterErrorLeaves is a filter that filters out leaves that are in error.

Parameters:

  • leaf: The leaf to filter.

Returns:

  • bool: True if the leaf is in error, false otherwise.

func FilterIncompleteLeaves

func FilterIncompleteLeaves[O any](h uc.Pair[EvalStatus, O]) bool

FilterIncompleteLeaves is a filter that filters out incomplete leaves.

Parameters:

  • leaf: The leaf to filter.

Returns:

  • bool: True if the leaf is incomplete, false otherwise.

func HelperWeightFunc

func HelperWeightFunc[O any](h []uc.Pair[EvalStatus, O]) (float64, bool)

HelperWeightFunc is a weight function that returns the length of the helper tokens.

Parameters:

  • h: The helper tokens to weigh.

Returns:

  • float64: The weight of the helper tokens.
  • bool: True if the weight is valid, false otherwise.

Types

type ErrAllMatchesFailed

type ErrAllMatchesFailed struct{}

ErrAllMatchesFailed is an error that is returned when all matches fail.

func NewErrAllMatchesFailed

func NewErrAllMatchesFailed() *ErrAllMatchesFailed

NewErrAllMatchesFailed creates a new error of type *ErrAllMatchesFailed.

Returns:

  • *ErrAllMatchesFailed: The new error.

func (*ErrAllMatchesFailed) Error

func (e *ErrAllMatchesFailed) Error() string

Error returns the error message: "all matches failed".

Returns:

  • string: The error message.

type ErrInvalidElement

type ErrInvalidElement struct{}

ErrInvalidElement is an error that is returned when an invalid element is found.

func NewErrInvalidElement

func NewErrInvalidElement() *ErrInvalidElement

NewErrInvalidElement creates a new error of type *ErrInvalidElement.

Returns:

  • *ErrInvalidElement: The new error.

func (*ErrInvalidElement) Error

func (e *ErrInvalidElement) Error() string

Error returns the error message: "invalid element".

Returns:

  • string: The error message.

type EvalStatus

type EvalStatus int

EvalStatus represents the status of an evaluation.

const (
	// EvalComplete represents a completed evaluation.
	EvalComplete EvalStatus = iota

	// EvalIncomplete represents an incomplete evaluation.
	EvalIncomplete

	// EvalError represents an evaluation that has an error.
	EvalError
)

func (EvalStatus) String

func (s EvalStatus) String() string

String implements fmt.Stringer interface.

type FilterBranchesFunc

type FilterBranchesFunc[O any] func(branches [][]uc.Pair[EvalStatus, O]) ([][]uc.Pair[EvalStatus, O], error)

FilterBranchesFunc is a function that filters branches.

Parameters:

  • branches: The branches to filter.

Returns:

  • [][]*CurrentEval: The filtered branches.
  • error: An error if the branches are invalid.

type MatchResulter

type MatchResulter[O any] interface {
	// GetMatch returns the match.
	//
	// Returns:
	//   - O: The match.
	GetMatch() O
}

MatchResult is an interface that represents a match result.

type Matcher

type Matcher[R MatchResulter[O], O any] interface {
	// IsDone is a function that checks if the matcher is done.
	//
	// Parameters:
	//   - from: The starting position of the match.
	//
	// Returns:
	//   - bool: True if the matcher is done, false otherwise.
	IsDone(from int) bool

	// Match is a function that matches the element.
	//
	// Parameters:
	//   - from: The starting position of the match.
	//
	// Returns:
	//   - []R: The list of matched results.
	//   - error: An error if the matchers cannot be created.
	Match(from int) ([]R, error)

	// SelectBestMatches selects the best matches from the list of matches.
	// Usually, the best matches' euristic is the longest match.
	//
	// Parameters:
	//   - matches: The list of matches.
	//
	// Returns:
	//   - []T: The best matches.
	SelectBestMatches(matches []R) []R

	// GetNext is a function that returns the next position of an element.
	//
	// Parameters:
	//   - elem: The element to get the next position of.
	//
	// Returns:
	//   - int: The next position of the element.
	GetNext(elem O) int
}

Matcher is an interface that represents a matcher.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL