Documentation ¶
Overview ¶
This package defines abstractions that are useful to agents that perform a recursive descent while processing.
For more details on this package see:
Index ¶
- func CompareValues(first any, second any) bool
- func FormatValue(value any) string
- func RankValues(first any, second any) int
- func SortArray[T any](array []T, rank Rank)
- type AgentStateLike
- type CollatorLike
- type Compare
- type Format
- type FormatterLike
- type FormatterStateLike
- type Rank
- type Sort
- type SorterLike
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CompareValues ¶
This function determines whether or not the specified values are equal using their natural comparison criteria.
func FormatValue ¶ added in v0.16.0
This function returns a canonical BDN string for the specified value.
func RankValues ¶
This function ranks the specified values based on their natural ordering.
Types ¶
type AgentStateLike ¶ added in v0.16.0
This interface defines the methods that all formatter states must implement.
func AgentState ¶ added in v0.16.0
func AgentState() AgentStateLike
This constructor creates a new agent state.
type CollatorLike ¶ added in v0.16.0
type CollatorLike interface { CompareValues(first any, second any) bool RankValues(first any, second any) int }
This interface defines the methods supported by all collator-like agent types that can compare and rank two values.
func Collator ¶ added in v0.16.0
func Collator() CollatorLike
This constructor creates a new instance of a formatter that can be used to generate the natural string format for any value.
type Compare ¶
This type defines the function signature for any function that can determine whether or not two specified values are equal to each other.
type Format ¶ added in v0.16.0
This type defines the function signature for any function that can format a value as a canoncial string.
type FormatterLike ¶ added in v0.16.0
This interface defines the methods supported by all agents that can generate a canonical string representation for a value.
func Formatter ¶
func Formatter() FormatterLike
This constructor creates a new instance of a formatter that can be used to generate the canonical string format for any value.
func FormatterWithIndentation ¶ added in v0.16.0
func FormatterWithIndentation(indentation int) FormatterLike
This constructor creates a new instance of a formatter that can be used to generate the canonical string format for any value using the specified initial indentation level.
type FormatterStateLike ¶ added in v0.16.0
type FormatterStateLike interface { AgentStateLike GetIndentation() int AppendString(s string) AppendNewline() GetResult() string }
This interface defines the methods that all formatter states must implement.
func FormatterState ¶
func FormatterState() FormatterStateLike
This constructor creates a new formatter state with no indentation.
func FormatterStateWithIndentation ¶ added in v0.16.0
func FormatterStateWithIndentation(indentation int) FormatterStateLike
This constructor creates a new formatter state with the specified indentation.
type Rank ¶
This type defines the function signature for any function that can determine the relative ordering of two specified values. The result must be one of the following:
- -1: The first value is less than the second value.
- 0: The first value is equal to the second value.
- 1: The first value is more than the second value.
type Sort ¶ added in v0.16.0
This type defines the function signature for any function that can sort an array of items using a ranking function.
type SorterLike ¶ added in v0.16.0
type SorterLike[T any] interface { SortArray(array []T) }
This interface defines the methods supported by all sorter-like agents that can sort an array of items using a ranking function.
func Sorter ¶ added in v0.16.0
func Sorter[T any](rank Rank) SorterLike[T]
This constructor creates a new instance of a sorter that can be used to sort an array using a specific ranking function.