heap

package
v2.1.3 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2024 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Heap

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

Heap 结构体表示一个堆,它包含一个链表。 The Heap struct represents a heap, which contains a list.

func New

func New() *Heap

New 函数创建并返回一个新的 Heap 实例。 The New function creates and returns a new Heap instance.

func (*Heap) Back

func (h *Heap) Back() *lst.Node

Back 方法返回堆的最后一个节点。 The Back method returns the last node of the heap.

func (*Heap) Cleanup

func (h *Heap) Cleanup()

Cleanup 方法清理堆,移除所有节点。 The Cleanup method cleans up the heap, removing all nodes.

func (*Heap) Front

func (h *Heap) Front() *lst.Node

Front 方法返回堆的第一个节点。 The Front method returns the first node of the heap.

func (*Heap) GetList

func (h *Heap) GetList() *lst.List

GetList 方法返回堆的内部列表。 The GetList method returns the internal list of the heap.

func (*Heap) Len

func (h *Heap) Len() int64

Len 方法返回堆的长度。 The Len method returns the length of the heap.

func (*Heap) Pop

func (h *Heap) Pop() *lst.Node

Pop 方法移除并返回堆的第一个节点。 The Pop method removes and returns the first node of the heap.

func (*Heap) Push

func (h *Heap) Push(n *lst.Node)

Push 方法将一个新的节点添加到堆中。 The Push method adds a new node to the heap.

func (*Heap) Range

func (h *Heap) Range(fn func(*lst.Node) bool)

Range 方法对堆中的每个节点执行函数 fn。 The Range method executes function fn for each node in the heap.

func (*Heap) Remove

func (h *Heap) Remove(node *lst.Node)

Remove 方法从堆中移除节点 node。 The Remove method removes the node from the heap.

func (*Heap) Slice

func (h *Heap) Slice() []interface{}

Slice 方法返回堆中所有节点的切片。 The Slice method returns a slice of all nodes in the heap.

Jump to

Keyboard shortcuts

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