Documentation
¶
Index ¶
- func Reduce[T any, R any](l *List[T], init R, fn func(acc R, v T, i int) R) R
- type List
- func (l *List[T]) Append(items ...T)
- func (l *List[T]) At(i int) (T, bool)
- func (l *List[T]) Cap() int
- func (l *List[T]) Clear()
- func (l *List[T]) Clone() *List[T]
- func (l *List[T]) CopyWithin(target int, start int, endOpt ...int)
- func (l *List[T]) Count(value T, eq func(a, b T) bool) int
- func (l *List[T]) Every(pred func(v T, i int) bool) bool
- func (l *List[T]) Extend(xs []T)
- func (l *List[T]) Fill(value T, startEnd ...int)
- func (l *List[T]) Filter(pred func(v T, i int) bool) *List[T]
- func (l *List[T]) Find(pred func(v T, i int) bool) (T, bool)
- func (l *List[T]) FindIndex(pred func(v T, i int) bool) int
- func (l *List[T]) FindLast(pred func(v T, i int) bool) (T, bool)
- func (l *List[T]) FindLastIndex(pred func(v T, i int) bool) int
- func (l *List[T]) ForEach(fn func(v T, i int))
- func (l *List[T]) ForEachAsync(ctx context.Context, maxGoroutines int, fn func(v T, i int)) error
- func (l *List[T]) Get(i int) T
- func (l *List[T]) Includes(value T, eq func(a, b T) bool) bool
- func (l *List[T]) IndexOf(value T, eq func(a, b T) bool) int
- func (l *List[T]) Insert(i int, v T)
- func (l *List[T]) Join(sep string, toStr func(v T) string) string
- func (l *List[T]) LastIndexOf(value T, eq func(a, b T) bool) int
- func (l *List[T]) Len() int
- func (l *List[T]) Map(fn func(v T, i int) any) *List[any]
- func (l *List[T]) MapInPlace(fn func(v T, i int) T)
- func (l *List[T]) Pop() (T, bool)
- func (l *List[T]) Push(items ...T)
- func (l *List[T]) RemoveAt(i int) (T, bool)
- func (l *List[T]) RemoveFirst(value T, eq func(a, b T) bool) bool
- func (l *List[T]) Reverse()
- func (l *List[T]) Set(i int, v T)
- func (l *List[T]) Shift() (T, bool)
- func (l *List[T]) Slice(startEnd ...int) *List[T]
- func (l *List[T]) Some(pred func(v T, i int) bool) bool
- func (l *List[T]) Sort(less func(a, b T) bool)
- func (l *List[T]) Splice(start, deleteCount int, items ...T) *List[T]
- func (l *List[T]) String() string
- func (l *List[T]) ToReversed() *List[T]
- func (l *List[T]) ToSlice() []T
- func (l *List[T]) ToSorted(less func(a, b T) bool) *List[T]
- func (l *List[T]) ToSpliced(start, deleteCount int, items ...T) *List[T]
- func (l *List[T]) Unshift(items ...T)
- func (l *List[T]) With(i int, v T) *List[T]
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type List ¶
type List[T any] struct { // contains filtered or unexported fields }
List 是一个通用的动态数组容器,模仿 Python 的 list 和 JavaScript 的 Array,支持常用的增删查改等操作。
func MapAsync ¶
func MapAsync[T any, R any]( ctx context.Context, l *List[T], maxGoroutines int, fn func(v T, i int) R, ) (*List[R], error)
MapAsync 并发映射 List,返回新 List。
func (*List[T]) CopyWithin ¶
CopyWithin 将指定区间的元素复制到目标位置。
func (*List[T]) FindLastIndex ¶
FindLastIndex 返回最后一个满足条件的元素索引。
func (*List[T]) ForEachAsync ¶
func (l *List[T]) ForEachAsync( ctx context.Context, maxGoroutines int, fn func(v T, i int), ) error
ForEachAsync 并发只读遍历 List,支持最大 goroutine 数。
func (*List[T]) LastIndexOf ¶
LastIndexOf 返回最后一个等于 value 的索引,未找到返回 -1。
func (*List[T]) MapInPlace ¶
T -> T, in place MapInPlace 原地映射 List 元素。
func (*List[T]) RemoveFirst ¶
RemoveFirst 移除第一个等于 value 的元素,eq 为比较器。
Click to show internal directories.
Click to hide internal directories.