linkedlist

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2025 License: MIT, Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseLinkedList

type BaseLinkedList[T comparable] struct {
	// contains filtered or unexported fields
}

链表

func NewBaseLinkedList

func NewBaseLinkedList[T comparable]() *BaseLinkedList[T]

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

func (*BaseLinkedList[T]) Append

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

在链表尾部添加数据

func (*BaseLinkedList[T]) Delete

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

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

func (*BaseLinkedList[T]) DeleteNode

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

删除指定结点

func (*BaseLinkedList[T]) Exist

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

是否含有指定结点

func (*BaseLinkedList[T]) GetNode

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

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

func (*BaseLinkedList[T]) Insert

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

在指定下标处插入数据

func (*BaseLinkedList[T]) InsertAfterData

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

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

func (*BaseLinkedList[T]) InsertAfterNode

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

在指定结点后面插入数据

func (*BaseLinkedList[T]) InsertHead

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

在链表头部插入数据

func (*BaseLinkedList[T]) IsEmpty

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

是否为空链表

func (*BaseLinkedList[T]) Len

func (l *BaseLinkedList[T]) Len() int

获取链表长度

func (*BaseLinkedList[T]) Pop

func (q *BaseLinkedList[T]) Pop() (T, bool)

func (*BaseLinkedList[T]) Push

func (q *BaseLinkedList[T]) Push(data T)

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]) GetNode

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

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

func (*LinkedList[T]) Insert

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

在指定下标处插入数据

func (*LinkedList[T]) InsertAfterData

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

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

func (*LinkedList[T]) InsertAfterNode

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

在指定结点后面插入数据

func (*LinkedList[T]) InsertHead

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

在链表头部插入数据

func (*LinkedList[T]) IsEmpty

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

是否为空链表

func (*LinkedList[T]) Len

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

获取链表长度

type Node

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

链表结点

func (*Node[T]) Next

func (n *Node[T]) Next() *Node[T]

func (*Node[T]) Previous

func (n *Node[T]) Previous() *Node[T]

Jump to

Keyboard shortcuts

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