topo

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2020 License: Apache-2.0 Imports: 2 Imported by: 0

README

Topo

topological sorting of directed acyclic graph

go get github.com/partyzanex/topo

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrVertexDefined = errors.New("vertex is defined")

Functions

This section is empty.

Types

type SortableEntity

type SortableEntity interface {
	// returns entity id
	Self() interface{}
	// returns id of parent entity
	Parent() interface{}
	// set children elements
	SetChildren(interface{})
}

SortableEntity interface for sortable entities

type TopologicalSorter

type TopologicalSorter struct {
	// contains filtered or unexported fields
}

TopologicalSorter represents service for sorting and searching entities

func New

func New() *TopologicalSorter

New is a constructor for TopologicalSorter

func (TopologicalSorter) Child

func (ts TopologicalSorter) Child(parent interface{}) ([]interface{}, error)

Child returns children entities by parent id

func (*TopologicalSorter) Exists

func (ts *TopologicalSorter) Exists(parent, self int) bool

Exists checks for exists by parent and self values

func (*TopologicalSorter) Push

func (ts *TopologicalSorter) Push(entity SortableEntity) error

Push adds entities for sorting

func (*TopologicalSorter) PushAll

func (ts *TopologicalSorter) PushAll(entities ...SortableEntity) (err error)

PushAll adds from entities slice for sorting

Jump to

Keyboard shortcuts

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