mygo

package module
v0.0.0-...-1bf82e4 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2024 License: MIT Imports: 4 Imported by: 0

README

mygo

Some data structures for Go

A8CEA924DC02CA679DCEE284F5BAD717.jpg

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PrintLinkList(head *LinkNode) error

PrintLinkList 打印链表

Types

type ArrayQueue

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

ArrayQueue 数组队列

func (*ArrayQueue) Add

func (q *ArrayQueue) Add(v int)

Add 数组队列入队

func (*ArrayQueue) Remove

func (q *ArrayQueue) Remove() (int, error)

Remove 数组队列出队

type ArrayStack

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

ArrayStack 数组栈

func (*ArrayStack) IsEmpty

func (s *ArrayStack) IsEmpty() bool

IsEmpty 数组栈判断是否为空

func (*ArrayStack) Peek

func (s *ArrayStack) Peek() (int, error)

Peek 数组栈查看栈顶元素

func (*ArrayStack) Pop

func (s *ArrayStack) Pop() (int, error)

Pop 数组栈出栈

func (*ArrayStack) Push

func (s *ArrayStack) Push(v int)

Push 数组栈入栈

func (*ArrayStack) Size

func (s *ArrayStack) Size() int

Size 数组栈查看栈大小

type Item

type Item struct {
	Value    int // 值
	Priority int // 优先级
	Index    int // 索引
}

Item 实现优先队列中的一个元素(一项).

type LinkNode

type LinkNode struct {
	Val  int
	Next *LinkNode
}

LinkNode 定义链表节点结构体

func NewLinkList(nums []int) (*LinkNode, error)

NewLinkList NewListList 通过[]int创建一个链表

type LinkQueue

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

LinkQueue 链表队列

func (*LinkQueue) Add

func (q *LinkQueue) Add(v int)

Add 链表队列入队

func (*LinkQueue) Remove

func (q *LinkQueue) Remove() (int, error)

Remove 链表队列出队

type LinkStack

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

LinkStack 链表栈

func (*LinkStack) IsEmpty

func (s *LinkStack) IsEmpty() bool

IsEmpty 链表栈判断是否为空

func (*LinkStack) Peek

func (s *LinkStack) Peek() (int, error)

Peek 链表栈查看栈顶元素

func (*LinkStack) Pop

func (s *LinkStack) Pop() (int, error)

Pop 链表栈出栈

func (*LinkStack) Push

func (s *LinkStack) Push(v int)

Push 链表栈入栈

func (*LinkStack) Size

func (s *LinkStack) Size() int

Size 链表栈查看栈大小

type PriorityQueue

type PriorityQueue []*Item

PriorityQueue 实现接口.

func (*PriorityQueue) Len

func (pq *PriorityQueue) Len() int

Len 返回优先队列长度.

func (*PriorityQueue) Less

func (pq *PriorityQueue) Less(i, j int) bool

Less 比较两个项优先级.

func (*PriorityQueue) Pop

func (pq *PriorityQueue) Pop() interface{}

Pop 移除并返回优先级最高的项.

func (*PriorityQueue) Push

func (pq *PriorityQueue) Push(x interface{})

Push 向优先队列中添加项.

func (*PriorityQueue) Swap

func (pq *PriorityQueue) Swap(i, j int)

Swap 交换两个项.

func (*PriorityQueue) Update

func (pq *PriorityQueue) Update(item *Item, value int, priority int)

Update 修改优先级和值的item在优先级队列中的位置.

Jump to

Keyboard shortcuts

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