linkedlist

package
v0.0.0-...-f5948c0 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2023 License: MIT Imports: 2 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 comparable] struct {
	// contains filtered or unexported fields
}

链表

func New

func New[T comparable]() LinkedList[T]

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

func (*LinkedList[T]) Append

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

在链表尾部添加数据

func (*LinkedList[T]) Delete

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

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

func (*LinkedList[T]) DeleteNode

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

删除指定结点

func (*LinkedList[T]) Exist

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

是否含有指定结点

func (*LinkedList[T]) GetLength

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

获取链表长度

func (*LinkedList[T]) GetNode

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

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

func (*LinkedList[T]) Insert

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

在指定下标处插入数据

func (*LinkedList[T]) InsertAfterData

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

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

func (*LinkedList[T]) InsertAfterNode

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

在指定结点后面插入数据

func (*LinkedList[T]) InsertHead

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

在链表头部插入数据

func (*LinkedList[T]) IsEmpty

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

是否为空链表

func (*LinkedList[T]) PrintInfo

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

打印链表信息

type Node

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

链表结点

Jump to

Keyboard shortcuts

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