Documentation
¶
Index ¶
- func SplitKList[T comparable](l *KList[T], limit int) [][]T
- func ToKSlice[T comparable](l *KList[T]) []T
- func ToSlice[T any](l *list.List) []T
- func ToSliceIf[T any](l *list.List, callback func(item T) bool) []T
- type KElement
- type KList
- func (l *KList[E]) At(index int) *E
- func (l *KList[E]) Back() *KElement[E]
- func (l *KList[E]) Clear()
- func (l *KList[E]) FindAllIf(callback func(v E) bool) []E
- func (l *KList[E]) FindIf(callback func(v E) bool) *E
- func (l *KList[E]) Front() *KElement[E]
- func (l *KList[E]) Init() *KList[E]
- func (l *KList[E]) InsertAfter(v E, mark *KElement[E]) *KElement[E]
- func (l *KList[E]) InsertBefore(v E, mark *KElement[E]) *KElement[E]
- func (l *KList[E]) Len() int
- func (l *KList[E]) MoveAfter(e, mark *KElement[E])
- func (l *KList[E]) MoveBefore(e, mark *KElement[E])
- func (l *KList[E]) MoveToBack(e *KElement[E])
- func (l *KList[E]) MoveToFront(e *KElement[E])
- func (l *KList[E]) PopAllIf(callback func(v E) bool) []E
- func (l *KList[E]) PopBack() *E
- func (l *KList[E]) PopFront() *E
- func (l *KList[E]) PopIf(callback func(v E) bool) *E
- func (l *KList[E]) PushBack(v E) *KElement[E]
- func (l *KList[E]) PushBackList(other *KList[E])
- func (l *KList[E]) PushBackSlice(v ...E) *KElement[E]
- func (l *KList[E]) PushFront(v E) *KElement[E]
- func (l *KList[E]) PushFrontList(other *KList[E])
- func (l *KList[E]) PushFrontSlice(v ...E) *KElement[E]
- func (l *KList[E]) Remove(e *KElement[E]) E
- func (l KList[E]) String() string
- func (l KList[E]) ToJson5(ident string) string
- func (l KList[E]) ToString() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SplitKList ¶
func SplitKList[T comparable](l *KList[T], limit int) [][]T
splitKList 将传入的KList类型的切片l按照给定的limit进行拆分,返回拆分后的结果
参数:
l *klists.KList[T] - 待拆分的KList类型的切片 limit int - 拆分后每个子切片的最大长度
返回值:
[]T - 拆分后的结果切片
Types ¶
type KElement ¶
type KElement[E comparable] struct { // The value stored with this element. Value E // contains filtered or unexported fields }
Element is an element of a linked list.
type KList ¶
type KList[E comparable] struct { // contains filtered or unexported fields }
List represents a doubly linked list. The zero value for List is an empty list ready to use.
func FilterFunc ¶
func FilterFunc[T comparable](l *KList[T], callback func(v T) bool) *KList[T]
func (*KList[E]) InsertAfter ¶
InsertAfter inserts a new element e with value v immediately after mark and returns e. If mark is not an element of l, the list is not modified. The mark must not be nil.
func (*KList[E]) InsertBefore ¶
InsertBefore inserts a new element e with value v immediately before mark and returns e. If mark is not an element of l, the list is not modified. The mark must not be nil.
func (*KList[E]) MoveAfter ¶
MoveAfter moves element e to its new position after mark. If e or mark is not an element of l, or e == mark, the list is not modified. The element and mark must not be nil.
func (*KList[E]) MoveBefore ¶
MoveBefore moves element e to its new position before mark. If e or mark is not an element of l, or e == mark, the list is not modified. The element and mark must not be nil.
func (*KList[E]) MoveToBack ¶
MoveToBack moves element e to the back of list l. If e is not an element of l, the list is not modified. The element must not be nil.
func (*KList[E]) MoveToFront ¶
MoveToFront moves element e to the front of list l. If e is not an element of l, the list is not modified. The element must not be nil.
func (*KList[E]) PushBack ¶
PushBack inserts a new element e with value v at the back of list l and returns e.
func (*KList[E]) PushBackList ¶
PushBackList inserts a copy of another list at the back of list l. The lists l and other may be the same. They must not be nil.
func (*KList[E]) PushBackSlice ¶
PushBack inserts a new element e with value v at the back of list l and returns e.
func (*KList[E]) PushFront ¶
PushFront inserts a new element e with value v at the front of list l and returns e.
func (*KList[E]) PushFrontList ¶
PushFrontList inserts a copy of another list at the front of list l. The lists l and other may be the same. They must not be nil.