algorithm

package
v1.3.5-alpha-0814 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2024 License: AGPL-3.0, MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Min

func Min(a, b int) int

Types

type Edge

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

func NewEdge

func NewEdge(from Node, to Node) *Edge

type Node

type Node interface {
	Next() []Node
	Prev() []Node
	Handler(*Node) any
}

节点

type Queue added in v1.3.3

type Queue[T comparable] struct {
	// contains filtered or unexported fields
}

Queue implements a FIFO Queue data structure.

func NewQueue added in v1.3.3

func NewQueue[T comparable]() *Queue[T]

NewQueue creates a new FIFO queue where the items are stored in a plain slice.

func (*Queue[T]) Clear added in v1.3.3

func (q *Queue[T]) Clear()

Clear erase all the items from the queue.

func (*Queue[T]) Dequeue added in v1.3.3

func (q *Queue[T]) Dequeue() (item T, err error)

Dequeue retrieves and removes the first element from the queue. The queue size will be decreased by one.

func (*Queue[T]) Enqueue added in v1.3.3

func (q *Queue[T]) Enqueue(item T)

Enqueue inserts a new element at the end of the queue.

func (*Queue[T]) ForEach added in v1.3.3

func (q *Queue[T]) ForEach(f func(T))

func (*Queue[T]) Len added in v1.3.3

func (q *Queue[T]) Len() int

Size returns the FIFO queue size.

func (*Queue[T]) Peek added in v1.3.3

func (q *Queue[T]) Peek() (item T)

Peek returns the first element of the queue without removing it.

func (*Queue[T]) Search added in v1.3.3

func (q *Queue[T]) Search(item T) bool

Search searches for an element in the queue.

func (*Queue[T]) Size added in v1.3.3

func (q *Queue[T]) Size() int

type SccResult

type SccResult []SccResultItem

func (SccResult) GetScc

func (scc SccResult) GetScc(n Node) SccResultItem

type SccResultItem

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

func NewSccResult

func NewSccResult(scc *TrSCC) *SccResultItem

func Run

func Run(rootNode Node) []SccResultItem

func (*SccResultItem) InInput

func (scc *SccResultItem) InInput(n Node) bool

func (*SccResultItem) InNodes

func (scc *SccResultItem) InNodes(n Node) bool

func (*SccResultItem) InOutput

func (scc *SccResultItem) InOutput(n Node) bool

type TrSCC

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

func NewTrSCC

func NewTrSCC() *TrSCC

func (*TrSCC) Tarjan

func (scc *TrSCC) Tarjan(node Node)

计算强连通分量

Jump to

Keyboard shortcuts

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