container

package
v0.2.60 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: LGPL-2.1 Imports: 0 Imported by: 0

Documentation

Overview

Package container 提供常用的容器数据结构。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Element

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

Element 元素

func (*Element[T]) Escape

func (e *Element[T]) Escape()

Escape 从链表中删除

func (*Element[T]) Escaped

func (e *Element[T]) Escaped() bool

Escaped 是否已从链表中删除

func (*Element[T]) Next

func (e *Element[T]) Next() *Element[T]

Next 下一个元素

func (*Element[T]) Prev

func (e *Element[T]) Prev() *Element[T]

Prev 前一个元素

func (*Element[T]) Version added in v0.2.53

func (e *Element[T]) Version() int64

Version 创建时的数据变化版本

type List

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

List 链表,可以在遍历时在任意位置添加或删除元素,递归添加或删除元素时仍然能正常工作,非线程安全。

func NewList

func NewList[T any]() *List[T]

NewList 创建链表

func (*List[T]) Back

func (l *List[T]) Back() *Element[T]

Back 链表尾部

func (*List[T]) Front

func (l *List[T]) Front() *Element[T]

Front 链表头部

func (*List[T]) InsertAfter

func (l *List[T]) InsertAfter(value T, at *Element[T]) *Element[T]

InsertAfter 在链表指定位置后插入数据

func (*List[T]) InsertBefore

func (l *List[T]) InsertBefore(value T, at *Element[T]) *Element[T]

InsertBefore 在链表指定位置前插入数据

func (*List[T]) Len

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

Len 链表长度

func (*List[T]) MoveAfter

func (l *List[T]) MoveAfter(e, at *Element[T])

MoveAfter 移动元素至链表指定位置后

func (*List[T]) MoveBefore

func (l *List[T]) MoveBefore(e, at *Element[T])

MoveBefore 移动元素至链表指定位置前

func (*List[T]) MoveToBack

func (l *List[T]) MoveToBack(e *Element[T])

MoveToBack 移动元素至链表尾部

func (*List[T]) MoveToFront

func (l *List[T]) MoveToFront(e *Element[T])

MoveToFront 移动元素至链表头部

func (*List[T]) PushBack

func (l *List[T]) PushBack(value T) *Element[T]

PushBack 在链表尾部插入数据

func (*List[T]) PushBackList

func (l *List[T]) PushBackList(other *List[T])

PushBackList 在链表尾部插入其他链表,可以传入自身

func (*List[T]) PushFront

func (l *List[T]) PushFront(value T) *Element[T]

PushFront 在链表头部插入数据

func (*List[T]) PushFrontList

func (l *List[T]) PushFrontList(other *List[T])

PushFrontList 在链表头部插入其他链表,可以传入自身

func (*List[T]) Remove

func (l *List[T]) Remove(e *Element[T]) T

Remove 删除元素

func (*List[T]) ReversedTraversal added in v0.2.58

func (l *List[T]) ReversedTraversal(visitor func(e *Element[T]) bool)

ReversedTraversal 反向遍历元素

func (*List[T]) ReversedTraversalAt added in v0.2.58

func (l *List[T]) ReversedTraversalAt(visitor func(e *Element[T]) bool, at *Element[T])

ReversedTraversalAt 从指定位置开始反向遍历元素

func (*List[T]) Traversal

func (l *List[T]) Traversal(visitor func(e *Element[T]) bool)

Traversal 遍历元素

func (*List[T]) TraversalAt

func (l *List[T]) TraversalAt(visitor func(e *Element[T]) bool, at *Element[T])

TraversalAt 从指定位置开始遍历元素

func (*List[T]) Version added in v0.2.53

func (l *List[T]) Version() int64

Version 数据变化版本

Jump to

Keyboard shortcuts

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