link

package
v0.1.11 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2025 License: MIT Imports: 3 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CompareFn added in v0.1.10

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

CompareFn 定义比较函数,返回 true 表示 a < b

type DLink[T any] struct {

	// 自动扩容
	AutoLen bool
	// 返回被循环链表覆盖的值
	OnCover func(value T)
	// contains filtered or unexported fields
}
func NewDLink[T any]() *DLink[T]

双向循环链表 *非并发安全*

func (*DLink[T]) AddNode

func (l *DLink[T]) AddNode(n int64)

AddNode 扩容

func (*DLink[T]) Cap

func (l *DLink[T]) Cap() int64

func (*DLink[T]) DelNode

func (l *DLink[T]) DelNode(n int64) error

DelNode 缩容

func (*DLink[T]) Len

func (l *DLink[T]) Len() int64

func (*DLink[T]) Peek

func (l *DLink[T]) Peek() T

func (*DLink[T]) Pull

func (l *DLink[T]) Pull() (v T)

func (*DLink[T]) Push

func (l *DLink[T]) Push(value T)

func (*DLink[T]) Range

func (l *DLink[T]) Range() (out []T)

func (*DLink[T]) Size

func (l *DLink[T]) Size(size int64) error

type Node

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

type OnewayLinkInterface added in v0.1.10

type OnewayLinkInterface[T any] interface {
	Next() OnewayLinkInterface[T]
	SetNext(OnewayLinkInterface[T])
	Val() T
}

OnewayLinkInterface 链表节点

func MergeSort added in v0.1.10

func MergeSort[T any](head OnewayLinkInterface[T], less CompareFn[T]) OnewayLinkInterface[T]

MergeSort 对链表做稳定排序,返回排好序的新表头

Jump to

Keyboard shortcuts

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