Documentation
¶
Index ¶
- func IsAdjoin[T num.Q](p, q *Node[T]) bool
- type List
- func (this *List[T]) Clear()
- func (this *List[T]) Deduplicate() (removedNumber int)
- func (this *List[T]) DeepEqual(another *List[T]) (equal bool)
- func (this *List[T]) FindAfter(e T, p *Node[T], n int) (targetNode *Node[T])
- func (this *List[T]) FindBefore(e T, n int, p *Node[T]) (targetNode *Node[T])
- func (this *List[T]) FirstNode() *Node[T]
- func (this *List[T]) Get(r int) (element T)
- func (this *List[T]) InsertAfter(p *Node[T], e T) *Node[T]
- func (this *List[T]) InsertAsFirst(e T) *Node[T]
- func (this *List[T]) InsertAsLast(e T) *Node[T]
- func (this *List[T]) InsertBefore(p *Node[T], e T) *Node[T]
- func (this *List[T]) InsertionSort(p *Node[T], n int)
- func (this *List[T]) IsEmpty() (isEmpty bool)
- func (this *List[T]) LastNode() *Node[T]
- func (this *List[T]) PopBack() (element T)
- func (this *List[T]) PopFront() (element T)
- func (this *List[T]) PushBack(e T) *Node[T]
- func (this *List[T]) PushFront(e T) *Node[T]
- func (this *List[T]) Put(p *Node[T], e T)
- func (this *List[T]) Remove(node *Node[T]) (element T)
- func (this *List[T]) SearchBefore(e T, n int, p *Node[T]) (targetNode *Node[T])
- func (this *List[T]) SelectionSort(p *Node[T], n int)
- func (this *List[T]) Size() (size int)
- func (this *List[T]) String() (retString string)
- func (this *List[T]) ToSlice() (newSlice []T)
- func (this *List[T]) Uniquify() (removedNumber int)
- type Node
- func (this *Node[T]) DeepEqual(another *Node[T]) (equal bool)
- func (this *Node[T]) Get() (element T)
- func (this *Node[T]) InsertAsNext(e T) (xnode *Node[T])
- func (this *Node[T]) InsertAsPre(e T) (xnode *Node[T])
- func (this *Node[T]) InsertNodeAsNext(p *Node[T]) (xnode *Node[T])
- func (this *Node[T]) InsertNodeAsPre(p *Node[T]) (xnode *Node[T])
- func (this *Node[T]) IsBetween(p, q *Node[T]) bool
- func (this *Node[T]) MoveToAfter(targetNode *Node[T]) (xnode *Node[T])
- func (this *Node[T]) NextNode() *Node[T]
- func (this *Node[T]) PreNode() *Node[T]
- func (this *Node[T]) Put(e T) (element T)
- func (this *Node[T]) Remove() (element T)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type List ¶ added in v0.0.3
双向链表结构体定义,其中默认有两个哨兵节点:头节点header 和 尾节点trailer
func NewFormList ¶ added in v0.0.3
从已有列表复制构造,从自节点p起(包含p)的n个节点复制到新列表中
func (*List[T]) Deduplicate ¶ added in v0.0.3
唯一化,不要求列表元素有序
func (*List[T]) DeepEqual ¶ added in v0.0.3
值判等,以值相等原则进行比较 定义:一个列表在"内容视图"上的相等包括:容量、链表的元素序列 相等,忽略其中的指针
func (*List[T]) FindBefore ¶ added in v0.0.3
向前查找, 在节点p之前(不包括p本身)的n个节点中,从p向前查找元素e,返回第一个包含元素e的节点的地址
func (*List[T]) InsertAfter ¶ added in v0.0.3
插入后继节点,将e作为p的后继插入,返回新节点的地址
func (*List[T]) InsertAsFirst ¶ added in v0.0.3
作为首节点插入,将元素e作为整个列表的首节点插入
func (*List[T]) InsertAsLast ¶ added in v0.0.3
作为末节点插入,将元素e作为整个列表的末节点插入
func (*List[T]) InsertBefore ¶ added in v0.0.3
插入前驱节点,将e作为p的前驱插入,返回新节点的地址
func (*List[T]) InsertionSort ¶ added in v0.0.3
插入排序,对链表中自p开始(包括p)的连续n个元素做插入排序
func (*List[T]) PopBack ¶ added in v0.0.3
func (this *List[T]) PopBack() (element T)
弹出末节点 警告:不会检查链表是否为空,调用方需自行检查保证
func (*List[T]) PopFront ¶ added in v0.0.3
func (this *List[T]) PopFront() (element T)
弹出首节点 警告:不会检查链表是否为空,调用方需自行检查保证
func (*List[T]) SearchBefore ¶ added in v0.0.3
向前搜索,在节点p之前(不包括p)的n个节点中,向前逐个查找元素e,返回第一个不大于e的节点 由于数据结构本身的限制,有序列表的搜索并不会比无序列表更好
func (*List[T]) SelectionSort ¶ added in v0.0.3
选择排序,对链表中自p开始(包括p)的连续n个元素([p, p+n)区间)进行非降序排序
type Node ¶
链表节点定义
func FullNewNode ¶ added in v0.0.3
节点完全构造,提供节点的所有信息进行构造 提示:不会修改参数中被指向的节点,调用方需要自行调整被指向节点的指针信息
func (*Node[T]) InsertAsNext ¶ added in v0.0.3
元素后插入算法,作为当前节点的直接后继插入,返回插入节点的地址
func (*Node[T]) InsertAsPre ¶ added in v0.0.3
元素前插入算法,作为当前节点的直接前驱插入,返回插入节点的地址 提示:可以在链表的头部插入,即使头部没有前驱节点
func (*Node[T]) InsertNodeAsNext ¶ added in v0.0.3
节点后插入算法,将节点p作为当前节点的直接后继插入,返回插入后的后继节点
func (*Node[T]) InsertNodeAsPre ¶ added in v0.0.3
节点前插入算法,将节点p作为当前节点的直接后继插入,返回插入后的前驱节点
func (*Node[T]) MoveToAfter ¶ added in v0.0.3
节点移动,将本节点移动到节点p后方,返回移动后本节点的后继节点