algorithm

package
v0.0.0-...-2a667a7 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrBellmanFordOutOfRange = errors.New("BellmanFord: index out of range")
View Source
var ErrBinaryHeap117Empty = errors.New("BinaryHeap117: binary-heap is empty")
View Source
var ErrBinaryHeapEmpty = errors.New("BinaryHeap: binary-heap is empty")
View Source
var ErrDeque117Empty = errors.New("Deque117: deque is empty")
View Source
var ErrDequeEmpty = errors.New("Deque: deque is empty")
View Source
var ErrDijkstraOutOfRange = errors.New("Dijkstra: index out of range")
View Source
var ErrQueue117Empty = errors.New("Queue117: queue is empty")
View Source
var ErrQueueEmpty = errors.New("Queue: queue is empty")
View Source
var ErrStack117Empty = errors.New("Stack117: stack is empty")
View Source
var ErrStackEmpty = errors.New("Stack: stack is empty")
View Source
var ErrUnionFindOutOfRange = errors.New("UnionFind: index out of range")

Functions

This section is empty.

Types

type BellmanFord

type BellmanFord[T constraints.Integer | constraints.Float] struct {
	// contains filtered or unexported fields
}

func NewBellmanFord

func NewBellmanFord[T constraints.Integer | constraints.Float](n int, inf T) *BellmanFord[T]

func NewDefaultBellmanFord

func NewDefaultBellmanFord(n int) *BellmanFord[int]

func (*BellmanFord[T]) AddEdge

func (b *BellmanFord[T]) AddEdge(from, to int, cost T)

func (*BellmanFord[T]) BellmanFord

func (b *BellmanFord[T]) BellmanFord(s int) bool

func (*BellmanFord[T]) Distance

func (b *BellmanFord[T]) Distance(t int) T

func (*BellmanFord[T]) FindNegativeCycle

func (b *BellmanFord[T]) FindNegativeCycle() bool

func (*BellmanFord[T]) Infinity

func (b *BellmanFord[T]) Infinity() T

func (*BellmanFord[T]) Order

func (b *BellmanFord[T]) Order() int

func (*BellmanFord[T]) ShortestPath

func (b *BellmanFord[T]) ShortestPath(t int) []int

type BinaryHeap

type BinaryHeap[T any] struct {
	// contains filtered or unexported fields
}

func NewBinaryHeap

func NewBinaryHeap[T any](f BinaryHeapCompFunc[T]) *BinaryHeap[T]

func NewDefaultBinaryHeap

func NewDefaultBinaryHeap[T constraints.Ordered]() *BinaryHeap[T]

func (*BinaryHeap[T]) Empty

func (b *BinaryHeap[T]) Empty() bool

func (*BinaryHeap[T]) Pop

func (b *BinaryHeap[T]) Pop() T

func (*BinaryHeap[T]) Push

func (b *BinaryHeap[T]) Push(x T)

func (*BinaryHeap[T]) Size

func (b *BinaryHeap[T]) Size() int

func (*BinaryHeap[T]) Top

func (b *BinaryHeap[T]) Top() T

type BinaryHeap117

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

A binary-heap data structure.

func NewBinaryHeap117

func NewBinaryHeap117(f BinaryHeap117CmpFunc) *BinaryHeap117

Create a new binary-heap.

func NewDefaultBinaryHeap117

func NewDefaultBinaryHeap117() *BinaryHeap117

Create a new basic binary-heap.

func (*BinaryHeap117) Empty

func (b *BinaryHeap117) Empty() bool

Checks if the binary-heap is empty.

func (*BinaryHeap117) Pop

func (b *BinaryHeap117) Pop() interface{}

Removes and returns the largest element.

func (*BinaryHeap117) Push

func (b *BinaryHeap117) Push(x interface{})

Inserts an element into the binary-heap.

func (*BinaryHeap117) Size

func (b *BinaryHeap117) Size() int

Returns the number of elements.

func (*BinaryHeap117) Top

func (b *BinaryHeap117) Top() interface{}

Returns the largest element.

type BinaryHeap117CmpFunc

type BinaryHeap117CmpFunc func(a, b interface{}) bool

type BinaryHeapCompFunc

type BinaryHeapCompFunc[T any] func(a, b T) bool

type Deque

type Deque[T any] struct {
	Data *list.List
}

func NewDeque

func NewDeque[T any]() *Deque[T]

func (*Deque[T]) Back

func (dq *Deque[T]) Back() T

func (*Deque[T]) Empty

func (dq *Deque[T]) Empty() bool

func (*Deque[T]) Front

func (dq *Deque[T]) Front() T

func (*Deque[T]) PopBack

func (dq *Deque[T]) PopBack() T

func (*Deque[T]) PopFront

func (dq *Deque[T]) PopFront() T

func (*Deque[T]) PushBack

func (dq *Deque[T]) PushBack(x T)

func (*Deque[T]) PushBackRange

func (dq *Deque[T]) PushBackRange(v []T)

func (*Deque[T]) PushFront

func (dq *Deque[T]) PushFront(x T)

func (*Deque[T]) PushFrontRange

func (dq *Deque[T]) PushFrontRange(v []T)

func (*Deque[T]) Size

func (dq *Deque[T]) Size() int

type Deque117

type Deque117 struct {
	Data *list.List
}

A deque data structure.

func NewDeque117

func NewDeque117() *Deque117

Create a new deque.

func (*Deque117) Back

func (d *Deque117) Back() interface{}

Returns the last element.

func (*Deque117) Empty

func (d *Deque117) Empty() bool

Checks if the deque is empty.

func (*Deque117) Front

func (d *Deque117) Front() interface{}

Returns the first element.

func (*Deque117) PopBack

func (d *Deque117) PopBack() interface{}

Removes and returns the last element.

func (*Deque117) PopFront

func (d *Deque117) PopFront() interface{}

Removes and returns the first element.

func (*Deque117) PushBack

func (d *Deque117) PushBack(x interface{})

Inserts an element at the back.

func (*Deque117) PushBackRange

func (d *Deque117) PushBackRange(v []interface{})

Inserts elements at the back.

func (*Deque117) PushFront

func (d *Deque117) PushFront(x interface{})

Inserts an element at the front.

func (*Deque117) PushFrontRange

func (d *Deque117) PushFrontRange(v []interface{})

Inserts elements at the front.

func (*Deque117) Size

func (d *Deque117) Size() int

Returns the number of elements.

type Dijkstra

type Dijkstra[T constraints.Integer | constraints.Float] struct {
	// contains filtered or unexported fields
}

func NewDefaultDijkstra

func NewDefaultDijkstra(n int) *Dijkstra[int]

func NewDijkstra

func NewDijkstra[T constraints.Integer | constraints.Float](n int, inf T) *Dijkstra[T]

func (*Dijkstra[T]) AddEdge

func (d *Dijkstra[T]) AddEdge(from, to int, cost T)

func (*Dijkstra[T]) Dijkstra

func (d *Dijkstra[T]) Dijkstra(s int)

func (*Dijkstra[T]) Distance

func (d *Dijkstra[T]) Distance(t int) T

func (*Dijkstra[T]) Infinity

func (d *Dijkstra[T]) Infinity() T

func (*Dijkstra[T]) Order

func (d *Dijkstra[T]) Order() int

func (*Dijkstra[T]) ShortestPath

func (d *Dijkstra[T]) ShortestPath(t int) []int

type Queue

type Queue[T any] struct {
	Data []T
}

func NewQueue

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

func (*Queue[T]) Empty

func (q *Queue[T]) Empty() bool

func (*Queue[T]) Front

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

func (*Queue[T]) Pop

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

func (*Queue[T]) Push

func (q *Queue[T]) Push(x T)

func (*Queue[T]) PushRange

func (q *Queue[T]) PushRange(v []T)

func (*Queue[T]) Size

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

type Queue117

type Queue117 struct {
	Data []interface{}
}

A queue structure.

func NewQueue117

func NewQueue117() *Queue117

Create a new queue.

func (*Queue117) Empty

func (q *Queue117) Empty() bool

Checks if the queue is empty.

func (*Queue117) Front

func (q *Queue117) Front() interface{}

Returns the front element.

func (*Queue117) Pop

func (q *Queue117) Pop() interface{}

Removes and returns the front element.

func (*Queue117) Push

func (q *Queue117) Push(x interface{})

Inserts an element at the back.

func (*Queue117) PushRange

func (q *Queue117) PushRange(v []interface{})

Inserts an elements at the back.

func (*Queue117) Size

func (q *Queue117) Size() int

Returns the number of elements.

type Stack

type Stack[T any] struct {
	Data []T
}

func NewStack

func NewStack[T any]() *Stack[T]

func (*Stack[T]) Empty

func (s *Stack[T]) Empty() bool

func (*Stack[T]) Pop

func (s *Stack[T]) Pop() T

func (*Stack[T]) Push

func (s *Stack[T]) Push(x T)

func (*Stack[T]) PushRange

func (s *Stack[T]) PushRange(v []T)

func (*Stack[T]) Size

func (s *Stack[T]) Size() int

func (*Stack[T]) Top

func (s *Stack[T]) Top() T

type Stack117

type Stack117 struct {
	Data []interface{}
}

A stack structure.

func NewStack117

func NewStack117() *Stack117

Create a new stack.

func (*Stack117) Empty

func (s *Stack117) Empty() bool

Checks if the stack is empty.

func (*Stack117) Pop

func (s *Stack117) Pop() interface{}

Removes and returns the top element.

func (*Stack117) Push

func (s *Stack117) Push(x interface{})

Inserts an element at the top.

func (*Stack117) PushRange

func (s *Stack117) PushRange(v []interface{})

Inserts elements at the top.

func (*Stack117) Size

func (s *Stack117) Size() int

Returns the number of elements.

func (*Stack117) Top

func (s *Stack117) Top() interface{}

Returns the top element.

type UnionFind

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

func NewUnionFind

func NewUnionFind(n int) *UnionFind

func (*UnionFind) Gn

func (uf *UnionFind) Gn() int

func (*UnionFind) IsSame

func (uf *UnionFind) IsSame(x, y int) bool

func (*UnionFind) Reset

func (uf *UnionFind) Reset()

func (*UnionFind) Root

func (uf *UnionFind) Root(x int) int

func (*UnionFind) Size

func (uf *UnionFind) Size(x int) int

func (*UnionFind) Unite

func (uf *UnionFind) Unite(x, y int) bool

func (*UnionFind) Vn

func (uf *UnionFind) Vn() int

Jump to

Keyboard shortcuts

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