utils

package
v2.0.0-alpha+incompatible Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2018 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DependsOn

func DependsOn(k1, k2 string, deps map[string]KeySet, visited KeySet) bool

DependsOn returns true if k1 depends on k2 based on dependencies from <deps>.

func ErrorToString

func ErrorToString(err error) string

ErrorToString converts error to string.

func ProtoToString

func ProtoToString(message proto.Message) string

ProtoToString converts proto message to string.

func TopologicalOrder

func TopologicalOrder(keys KeySet, deps map[string]KeySet, depFirst bool, handleCycle bool) (sorted []string)

TopologicalOrder orders keys topologically by Kahn's algorithm to respect the given dependencies. deps = map{ key -> <set of keys the given key depends on> }

Types

type KeySet

type KeySet map[string]struct{}

KeySet is a set of keys.

func NewKeySet

func NewKeySet(keys ...string) KeySet

NewKeySet returns a new instance of empty KeySet.

func (KeySet) Add

func (ks KeySet) Add(key string) KeySet

Add adds key into the set.

func (KeySet) DeepCopy

func (ks KeySet) DeepCopy() KeySet

DeepCopy returns a deep-copy of the key set.

func (KeySet) Del

func (ks KeySet) Del(key string) KeySet

Del removes key from the set.

func (KeySet) Has

func (ks KeySet) Has(key string) bool

Has returns true if the given key is in the set.

func (KeySet) Intersect

func (ks KeySet) Intersect(ks2 KeySet) KeySet

Intersect returns a new key set that contains keys present in both sets.

func (KeySet) String

func (ks KeySet) String() string

String return human-readable string representation of the ket-set.

func (KeySet) Subtract

func (ks KeySet) Subtract(ks2 KeySet) KeySet

Subtract removes keys from <ks> that are in both key sets.

Jump to

Keyboard shortcuts

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