topo

package
v0.0.0-...-ff948a4 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDefaultCompareFunc

func NewDefaultCompareFunc[T, I comparable, O TopoInfo[T, I]](in iter.Seq[O], mapper IdProvider[T, I]) general.CompareFunc[O]

func NewStringIdCompareFunc

func NewStringIdCompareFunc[T comparable, O TopoInfo[T, string]](in iter.Seq[O]) general.CompareFunc[O]

func StringIdProviderFunc

func StringIdProviderFunc[T comparable](path []T) string

Types

type ComparerFactory

type ComparerFactory[O any] interface {
	Comparer(in iter.Seq[O]) general.CompareFunc[O]
}

func NewDefaultComparerFactory

func NewDefaultComparerFactory[T, I comparable, O TopoInfo[T, I]](mapper IdProvider[T, I]) ComparerFactory[O]

NewDefaultComparerFactory creates a ComparerFactory for a given IdProvider based on hierarchy level names of type T and an element identity type I. A hierarchy is a set of elements (O) where each element is either a top level element or has a parent also member of the element set. Such a set can be topologically sorted. The result is an element list, where every element is placed later in the list than its parent and earlier than all of its children. The order of elements at the same level is not determined. But an element may have additional attributes to its hierarchy information. Those attributes may imply an order for those elements in the resulting list. Such an order may be given by a preordered list of elements according to some desired sorting criteria. For example, by ordering the set by other attribute-based compare functions (for example, by a sort step of a processing chain. This function provides a general.CompareFunc, which can be used by a slices.Sort function to provide a topologically sorted element list obeying the element order of siblings found in the given initial list.

func NewStringIdComparerFactory

func NewStringIdComparerFactory[T comparable, O TopoInfo[T, string]]() ComparerFactory[O]

type ComparerFactoryFunc

type ComparerFactoryFunc[O any] func(in iter.Seq[O]) general.CompareFunc[O]

func (ComparerFactoryFunc[O]) Comparer

func (f ComparerFactoryFunc[O]) Comparer(in iter.Seq[O]) general.CompareFunc[O]

type DefaultComparer

type DefaultComparer[T, I comparable, O TopoInfo[T, I]] struct {
	// contains filtered or unexported fields
}

func (*DefaultComparer[T, I, O]) Compare

func (t *DefaultComparer[T, I, O]) Compare(a, b O) int

type DefaultTopoInfo

type DefaultTopoInfo[T, I comparable] struct {
	// contains filtered or unexported fields
}

func NewDefaultTopoInfo

func NewDefaultTopoInfo[T, I comparable](mapper IdProvider[T, I], key T, path history.History[T]) *DefaultTopoInfo[T, I]

func (*DefaultTopoInfo[T, I]) GetHierarchy

func (t *DefaultTopoInfo[T, I]) GetHierarchy() []T

func (*DefaultTopoInfo[T, I]) GetHistory

func (t *DefaultTopoInfo[T, I]) GetHistory() history.History[T]

func (*DefaultTopoInfo[T, I]) GetId

func (t *DefaultTopoInfo[T, I]) GetId() I

func (*DefaultTopoInfo[T, I]) GetKey

func (t *DefaultTopoInfo[T, I]) GetKey() T

type IdProvider

type IdProvider[T, I comparable] func([]T) I

type StringIdTopoInfo

type StringIdTopoInfo[T comparable] = DefaultTopoInfo[T, string]

type TopoInfo

type TopoInfo[T, I comparable] interface {
	history.HistoryProvider[T]

	GetHierarchy() []T

	// GetKey provides the name of the actual object.
	GetKey() T

	// GetId provides the globally unique id of the object.
	GetId() I
}

func NewStringIdTopoInfo

func NewStringIdTopoInfo[T comparable](key T, path history.History[T]) TopoInfo[T, string]

Jump to

Keyboard shortcuts

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