_04_singly_linked_list

package
v0.0.0-...-6d07767 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2025 License: MIT Imports: 3 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 struct {
	// contains filtered or unexported fields
}

单链表数据结构

func CreateHead

func CreateHead(nums int) *LinkedList

头插法实现链表整表创建

@return *LinkedList

func CreateTail

func CreateTail(nums int) *LinkedList

尾插法实现链表整表创建

@return *LinkedList

func NewLinkedList

func NewLinkedList() *LinkedList

模拟构造函数,构造一个单链表

@return *LinkedList

func (*LinkedList) Append

func (this *LinkedList) Append(element interface{})

func (*LinkedList) Clear

func (this *LinkedList) Clear()

func (*LinkedList) Delete

func (this *LinkedList) Delete(index int) interface{}

func (*LinkedList) GetElem

func (this *LinkedList) GetElem(index int) interface{}

func (*LinkedList) Insert

func (this *LinkedList) Insert(index int, element interface{})

func (*LinkedList) Print

func (this *LinkedList) Print()

打印链表结构

@receiver this

func (*LinkedList) ToArray

func (this *LinkedList) ToArray() []interface{}

ToArray 使用递归 + 闭包

@receiver this
@return []interface{}

type LinkedListInterface

type LinkedListInterface interface {
	// 插入操作,在结点之前插入
	//  @param int 第几个结点
	//  @param interface{} 插入的元素
	Insert(int, interface{})

	// 追加操作
	//  @param interface{}
	Append(interface{})

	// 删除操作
	//  @param int
	//  @return interface{}
	Delete(int) interface{}

	// 获取元素
	//  @param int
	//  @return interface{}
	GetElem(int) interface{}

	// 清空链表
	Clear()

	// 转换为数组
	ToArray() []interface{}

	// 打印链表
	Print()
}

type Node

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

单链表结点

Jump to

Keyboard shortcuts

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