linkedlist

package
v1.8.11 Latest Latest
Warning

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

Go to latest
Published: May 26, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LinkedList

type LinkedList[T cmp.CompareKey[V], V constraints.Ordered] struct {
	// contains filtered or unexported fields
}

链表

func New

func New[T cmp.CompareKey[V], V constraints.Ordered]() LinkedList[T, V]

新建空链表,即创建Node指针head,用来指向链表第一个结点,初始为空

func (*LinkedList[T, V]) Append

func (l *LinkedList[T, V]) Append(e T)

在链表尾部添加数据

func (*LinkedList[T, V]) Delete

func (l *LinkedList[T, V]) Delete(e T)

删除第一个含指定数据的结点

func (*LinkedList[T, V]) DeleteNode

func (l *LinkedList[T, V]) DeleteNode(node *Node[T, V])

删除指定结点

func (*LinkedList[T, V]) Exist

func (l *LinkedList[T, V]) Exist(node *Node[T, V]) bool

是否含有指定结点

func (*LinkedList[T, V]) GetLength

func (l *LinkedList[T, V]) GetLength() int

获取链表长度

func (*LinkedList[T, V]) GetNode

func (l *LinkedList[T, V]) GetNode(e T) *Node[T, V]

获取含有指定数据的第一个结点

func (*LinkedList[T, V]) Insert

func (l *LinkedList[T, V]) Insert(position int, e T) error

在指定下标处插入数据

func (*LinkedList[T, V]) InsertAfterData

func (l *LinkedList[T, V]) InsertAfterData(preData T, e T) error

在第一次出现指定数据的结点后插入数据,若链表中无该数据,返回false

func (*LinkedList[T, V]) InsertAfterNode

func (l *LinkedList[T, V]) InsertAfterNode(pre *Node[T, V], e T) error

在指定结点后面插入数据

func (*LinkedList[T, V]) InsertHead

func (l *LinkedList[T, V]) InsertHead(e T)

在链表头部插入数据

func (*LinkedList[T, V]) IsEmpty

func (l *LinkedList[T, V]) IsEmpty() bool

是否为空链表

func (*LinkedList[T, V]) PrintInfo

func (l *LinkedList[T, V]) PrintInfo()

打印链表信息

type Node

type Node[T cmp.CompareKey[V], V constraints.Ordered] struct {
	// contains filtered or unexported fields
}

链表结点

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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