listings

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

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]) Add

func (s *PagedSlice[T]) Add(value T)

Add 添加一个元素到 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]) Len

func (s *PagedSlice[T]) Len() int

Len 返回 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]) Append

func (slf *PrioritySlice[V]) Append(v V, p int)

Append 添加元素

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]) Cap

func (slf *PrioritySlice[V]) Cap() int

Cap 返回切片容量

func (*PrioritySlice[V]) Clear

func (slf *PrioritySlice[V]) Clear()

Clear 清空切片

func (*PrioritySlice[V]) Get

func (slf *PrioritySlice[V]) Get(index int) (V, int)

Get 获取元素

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]) Len

func (slf *PrioritySlice[V]) Len() int

Len 返回切片长度

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 设置元素值

func (*PrioritySlice[V]) Slice

func (slf *PrioritySlice[V]) Slice() []V

Slice 返回切片

func (*PrioritySlice[V]) String

func (slf *PrioritySlice[V]) String() string

String 返回切片字符串

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]) Cap

func (slf *SyncPrioritySlice[V]) Cap() int

Cap 返回切片容量

func (*SyncPrioritySlice[V]) Clear

func (slf *SyncPrioritySlice[V]) Clear()

Clear 清空切片

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]) Len

func (slf *SyncPrioritySlice[V]) Len() int

Len 返回切片长度

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]) Slice

func (slf *SyncPrioritySlice[V]) Slice() []V

Slice 返回切片

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

func NewSyncSlice[V any](length, cap int) *SyncSlice[V]

NewSyncSlice 创建一个 SyncSlice

func (*SyncSlice[V]) Append

func (slf *SyncSlice[V]) Append(values ...V)

func (*SyncSlice[V]) Clear

func (slf *SyncSlice[V]) Clear()

func (*SyncSlice[V]) Get

func (slf *SyncSlice[V]) Get(index int) V

func (*SyncSlice[V]) GetData

func (slf *SyncSlice[V]) GetData() []V

func (*SyncSlice[V]) GetWithRange

func (slf *SyncSlice[V]) GetWithRange(start, end int) []V

func (*SyncSlice[V]) Release

func (slf *SyncSlice[V]) Release()

func (*SyncSlice[V]) Set

func (slf *SyncSlice[V]) Set(index int, value V)

Jump to

Keyboard shortcuts

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