topo

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2019 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{}
}

interface for sortable entities

type TopologicalSorter

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

service for sorting and searching entities

func New

func New() *TopologicalSorter

constructor

func (TopologicalSorter) Child

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

getting children entities by parent id

func (*TopologicalSorter) Exists

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

check for exists by parent and self values

func (*TopologicalSorter) Push

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

adding entities for sorting

func (*TopologicalSorter) PushAll

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

adding from entities slice for sorting

Jump to

Keyboard shortcuts

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