Documentation ¶
Index ¶
- type LinkedList
- func (l *LinkedList[T, V]) Append(e T)
- func (l *LinkedList[T, V]) Delete(e T)
- func (l *LinkedList[T, V]) DeleteNode(node *Node[T, V])
- func (l *LinkedList[T, V]) Exist(node *Node[T, V]) bool
- func (l *LinkedList[T, V]) GetLength() int
- func (l *LinkedList[T, V]) GetNode(e T) *Node[T, V]
- func (l *LinkedList[T, V]) Insert(position int, e T) error
- func (l *LinkedList[T, V]) InsertAfterData(preData T, e T) error
- func (l *LinkedList[T, V]) InsertAfterNode(pre *Node[T, V], e T) error
- func (l *LinkedList[T, V]) InsertHead(e T)
- func (l *LinkedList[T, V]) IsEmpty() bool
- func (l *LinkedList[T, V]) PrintInfo()
- type Node
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]) DeleteNode ¶
func (l *LinkedList[T, V]) DeleteNode(node *Node[T, V])
删除指定结点
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
在指定结点后面插入数据
type Node ¶
type Node[T cmp.CompareKey[V], V constraints.Ordered] struct { // contains filtered or unexported fields }
链表结点
Click to show internal directories.
Click to hide internal directories.