Documentation ¶
Index ¶
- type PagedSlice
- func (s *PagedSlice[T]) Add(value T)
- func (s *PagedSlice[T]) BatchGrowSet(indexes []int, values []T)
- func (s *PagedSlice[T]) BatchSet(indexes []int, values []T)
- func (s *PagedSlice[T]) Del(index int)
- func (s *PagedSlice[T]) Get(index int) (v *T)
- func (s *PagedSlice[T]) Grow(indexes []int)
- func (s *PagedSlice[T]) GrowSet(index int, value T)
- func (s *PagedSlice[T]) Len() int
- func (s *PagedSlice[T]) Set(index int, value T)
- type PrioritySlice
- func (slf *PrioritySlice[V]) Action(action func(items []*priorityItem[V]) []*priorityItem[V])
- func (slf *PrioritySlice[V]) Append(v V, p int)
- func (slf *PrioritySlice[V]) AppendByOptionalPriority(v V, priority ...int)
- func (slf *PrioritySlice[V]) Appends(priority int, vs ...V)
- func (slf *PrioritySlice[V]) Cap() int
- func (slf *PrioritySlice[V]) Clear()
- func (slf *PrioritySlice[V]) Get(index int) (V, int)
- func (slf *PrioritySlice[V]) GetPriority(index int) int
- func (slf *PrioritySlice[V]) GetValue(index int) V
- func (slf *PrioritySlice[V]) Len() int
- func (slf *PrioritySlice[V]) Range(action func(index int, item *priorityItem[V]) bool)
- func (slf *PrioritySlice[V]) RangePriority(action func(index int, priority int) bool)
- func (slf *PrioritySlice[V]) RangeValue(action func(index int, value V) bool)
- func (slf *PrioritySlice[V]) Set(index int, value V, priority int)
- func (slf *PrioritySlice[V]) SetPriority(index int, priority int)
- func (slf *PrioritySlice[V]) SetValue(index int, value V)
- func (slf *PrioritySlice[V]) Slice() []V
- func (slf *PrioritySlice[V]) String() string
- type SyncPrioritySlice
- func (slf *SyncPrioritySlice[V]) Action(action func(items []*priorityItem[V]) []*priorityItem[V])
- func (slf *SyncPrioritySlice[V]) Append(v V, p int)
- func (slf *SyncPrioritySlice[V]) AppendByOptionalPriority(v V, priority ...int)
- func (slf *SyncPrioritySlice[V]) Appends(priority int, vs ...V)
- func (slf *SyncPrioritySlice[V]) Cap() int
- func (slf *SyncPrioritySlice[V]) Clear()
- func (slf *SyncPrioritySlice[V]) Get(index int) (V, int)
- func (slf *SyncPrioritySlice[V]) GetPriority(index int) int
- func (slf *SyncPrioritySlice[V]) GetValue(index int) V
- func (slf *SyncPrioritySlice[V]) Len() int
- func (slf *SyncPrioritySlice[V]) Range(action func(index int, item *priorityItem[V]) bool)
- func (slf *SyncPrioritySlice[V]) RangePriority(action func(index int, priority int) bool)
- func (slf *SyncPrioritySlice[V]) RangeValue(action func(index int, value V) bool)
- func (slf *SyncPrioritySlice[V]) Set(index int, value V, priority int)
- func (slf *SyncPrioritySlice[V]) SetPriority(index int, priority int)
- func (slf *SyncPrioritySlice[V]) SetValue(index int, value V)
- func (slf *SyncPrioritySlice[V]) Slice() []V
- func (slf *SyncPrioritySlice[V]) String() string
- type SyncSlice
- func (slf *SyncSlice[V]) Append(values ...V)
- func (slf *SyncSlice[V]) Clear()
- func (slf *SyncSlice[V]) Get(index int) V
- func (slf *SyncSlice[V]) GetData() []V
- func (slf *SyncSlice[V]) GetWithRange(start, end int) []V
- func (slf *SyncSlice[V]) Release()
- func (slf *SyncSlice[V]) Set(index int, value V)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PagedSlice ¶
type PagedSlice[T any] struct { // contains filtered or unexported fields }
PagedSlice 是一个高效的动态数组,它通过分页管理内存并减少频繁的内存分配来提高性能。
func NewPagedSlice ¶
func NewPagedSlice[T any](pageSize int) *PagedSlice[T]
NewPagedSlice 创建一个新的 PagedSlice 实例。
func (*PagedSlice[T]) BatchGrowSet ¶ added in v0.6.0
func (s *PagedSlice[T]) BatchGrowSet(indexes []int, values []T)
BatchGrowSet 批量设置给定索引的元素。
func (*PagedSlice[T]) BatchSet ¶ added in v0.6.0
func (s *PagedSlice[T]) BatchSet(indexes []int, values []T)
BatchSet 批量设置给定索引的元素。
func (*PagedSlice[T]) Del ¶ added in v0.6.0
func (s *PagedSlice[T]) Del(index int)
Del 删除 PagedSlice 中给定索引的元素。
func (*PagedSlice[T]) Get ¶
func (s *PagedSlice[T]) Get(index int) (v *T)
Get 获取 PagedSlice 中给定索引的元素。
func (*PagedSlice[T]) Grow ¶ added in v0.6.0
func (s *PagedSlice[T]) Grow(indexes []int)
Grow 扩容 PagedSlice 的长度但不设置值
func (*PagedSlice[T]) GrowSet ¶ added in v0.6.0
func (s *PagedSlice[T]) GrowSet(index int, value T)
GrowSet 扩展 PagedSlice 的长度并设置给定索引的元素。
func (*PagedSlice[T]) Set ¶
func (s *PagedSlice[T]) Set(index int, value T)
Set 设置 PagedSlice 中给定索引的元素。
type PrioritySlice ¶
type PrioritySlice[V any] struct { // contains filtered or unexported fields }
PrioritySlice 是一个优先级切片,优先级越低越靠前
func NewPrioritySlice ¶
func NewPrioritySlice[V any](lengthAndCap ...int) *PrioritySlice[V]
NewPrioritySlice 创建一个优先级切片,优先级越低越靠前
func (*PrioritySlice[V]) Action ¶
func (slf *PrioritySlice[V]) Action(action func(items []*priorityItem[V]) []*priorityItem[V])
Action 直接操作切片,如果返回值不为 nil,则替换切片
func (*PrioritySlice[V]) AppendByOptionalPriority ¶
func (slf *PrioritySlice[V]) AppendByOptionalPriority(v V, priority ...int)
AppendByOptionalPriority 添加元素
func (*PrioritySlice[V]) Appends ¶
func (slf *PrioritySlice[V]) Appends(priority int, vs ...V)
Appends 添加元素
func (*PrioritySlice[V]) GetPriority ¶
func (slf *PrioritySlice[V]) GetPriority(index int) int
GetPriority 获取元素优先级
func (*PrioritySlice[V]) GetValue ¶
func (slf *PrioritySlice[V]) GetValue(index int) V
GetValue 获取元素值
func (*PrioritySlice[V]) Range ¶
func (slf *PrioritySlice[V]) Range(action func(index int, item *priorityItem[V]) bool)
Range 遍历切片,如果返回值为 false,则停止遍历
func (*PrioritySlice[V]) RangePriority ¶
func (slf *PrioritySlice[V]) RangePriority(action func(index int, priority int) bool)
RangePriority 遍历切片优先级,如果返回值为 false,则停止遍历
func (*PrioritySlice[V]) RangeValue ¶
func (slf *PrioritySlice[V]) RangeValue(action func(index int, value V) bool)
RangeValue 遍历切片值,如果返回值为 false,则停止遍历
func (*PrioritySlice[V]) Set ¶
func (slf *PrioritySlice[V]) Set(index int, value V, priority int)
Set 设置元素
func (*PrioritySlice[V]) SetPriority ¶
func (slf *PrioritySlice[V]) SetPriority(index int, priority int)
SetPriority 设置元素优先级
func (*PrioritySlice[V]) SetValue ¶
func (slf *PrioritySlice[V]) SetValue(index int, value V)
SetValue 设置元素值
type SyncPrioritySlice ¶
type SyncPrioritySlice[V any] struct { // contains filtered or unexported fields }
SyncPrioritySlice 是一个优先级切片,优先级越低越靠前
func NewSyncPrioritySlice ¶
func NewSyncPrioritySlice[V any](lengthAndCap ...int) *SyncPrioritySlice[V]
NewSyncPrioritySlice 创建一个并发安全的优先级切片,优先级越低越靠前
func (*SyncPrioritySlice[V]) Action ¶
func (slf *SyncPrioritySlice[V]) Action(action func(items []*priorityItem[V]) []*priorityItem[V])
Action 直接操作切片,如果返回值不为 nil,则替换切片
func (*SyncPrioritySlice[V]) Append ¶
func (slf *SyncPrioritySlice[V]) Append(v V, p int)
Append 添加元素
func (*SyncPrioritySlice[V]) AppendByOptionalPriority ¶
func (slf *SyncPrioritySlice[V]) AppendByOptionalPriority(v V, priority ...int)
AppendByOptionalPriority 添加元素
func (*SyncPrioritySlice[V]) Appends ¶
func (slf *SyncPrioritySlice[V]) Appends(priority int, vs ...V)
Appends 添加元素
func (*SyncPrioritySlice[V]) Get ¶
func (slf *SyncPrioritySlice[V]) Get(index int) (V, int)
Get 获取元素
func (*SyncPrioritySlice[V]) GetPriority ¶
func (slf *SyncPrioritySlice[V]) GetPriority(index int) int
GetPriority 获取元素优先级
func (*SyncPrioritySlice[V]) GetValue ¶
func (slf *SyncPrioritySlice[V]) GetValue(index int) V
GetValue 获取元素值
func (*SyncPrioritySlice[V]) Range ¶
func (slf *SyncPrioritySlice[V]) Range(action func(index int, item *priorityItem[V]) bool)
Range 遍历切片,如果返回值为 false,则停止遍历
func (*SyncPrioritySlice[V]) RangePriority ¶
func (slf *SyncPrioritySlice[V]) RangePriority(action func(index int, priority int) bool)
RangePriority 遍历切片优先级,如果返回值为 false,则停止遍历
func (*SyncPrioritySlice[V]) RangeValue ¶
func (slf *SyncPrioritySlice[V]) RangeValue(action func(index int, value V) bool)
RangeValue 遍历切片值,如果返回值为 false,则停止遍历
func (*SyncPrioritySlice[V]) Set ¶
func (slf *SyncPrioritySlice[V]) Set(index int, value V, priority int)
Set 设置元素
func (*SyncPrioritySlice[V]) SetPriority ¶
func (slf *SyncPrioritySlice[V]) SetPriority(index int, priority int)
SetPriority 设置元素优先级
func (*SyncPrioritySlice[V]) SetValue ¶
func (slf *SyncPrioritySlice[V]) SetValue(index int, value V)
SetValue 设置元素值
func (*SyncPrioritySlice[V]) String ¶
func (slf *SyncPrioritySlice[V]) String() string
String 返回切片字符串
type SyncSlice ¶
type SyncSlice[V any] struct { // contains filtered or unexported fields }
SyncSlice 是基于 sync.RWMutex 实现的线程安全的 slice
func NewSyncSlice ¶
NewSyncSlice 创建一个 SyncSlice