container

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type KeyElement

type KeyElement[K cmp.Ordered] struct {
	Key  K
	Next *KeyElement[K]
}

KeyElement key结构

type LruCache added in v0.0.5

type LruCache[K comparable, V any] struct {
	// contains filtered or unexported fields
}

ShardLruCache 缓存

func NewLruCache added in v0.0.5

func NewLruCache[K comparable, V any](capacity int) *LruCache[K, V]

NewLruCache 构造函数

func (*LruCache[K, V]) Get added in v0.0.5

func (lru *LruCache[K, V]) Get(key K) (val V, ok bool)

Get 获取缓存信息

func (*LruCache[K, V]) Put added in v0.0.5

func (lru *LruCache[K, V]) Put(key K, val V, expireAt int64)

Put 放入元素到缓存

func (*LruCache[K, V]) Remove added in v0.0.5

func (lru *LruCache[K, V]) Remove(key K)

Remove 移除元素

type LruCache2Q added in v0.0.5

type LruCache2Q[K comparable, V any] struct {
	*LruCache[K, V] // lru 队列
	// contains filtered or unexported fields
}

Lru -2Q 模式

func NewLruCache2Q added in v0.0.5

func NewLruCache2Q[K comparable, V any](capacity int, expiration time.Duration) *LruCache2Q[K, V]

NewLruCache2Q 构造函数

func (*LruCache2Q[K, V]) Get added in v0.0.5

func (lru *LruCache2Q[K, V]) Get(key K) (val V, ok bool)

Get 从缓存中获取

func (*LruCache2Q[K, V]) Put added in v0.0.5

func (lru *LruCache2Q[K, V]) Put(key K, value V)

Put 元素放入缓存

func (*LruCache2Q[K, V]) Remove added in v0.0.5

func (lru *LruCache2Q[K, V]) Remove(key K)

Remove 删除缓存

type None

type None struct{}

type Queue

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

Queue 队列 线程不安全

func NewQueue

func NewQueue[T any]() *Queue[T]

NewQueue 创建队列

func (*Queue[T]) Clear

func (q *Queue[T]) Clear()

Clear 清空队列

func (*Queue[T]) Empty

func (q *Queue[T]) Empty() bool

Empty 判断队列是否为空

func (*Queue[T]) Pop

func (q *Queue[T]) Pop() (val T)

Pop 出队

func (*Queue[T]) Push

func (q *Queue[T]) Push(val T)

Push 入队

func (*Queue[T]) Size

func (q *Queue[T]) Size() int

Size 获取队列长度

func (*Queue[T]) Value

func (q *Queue[T]) Value() []T

Value 获取队列数据

type Set

type Set[T comparable] struct {
	// contains filtered or unexported fields
}

Set 集合

func NewSet

func NewSet[T comparable]() *Set[T]

NewSet 创建集合

func (*Set[T]) Add

func (s *Set[T]) Add(values ...T)

Add 添加值到集合中

func (*Set[T]) Clear

func (s *Set[T]) Clear()

Clear 清空集合

func (*Set[T]) Contains

func (s *Set[T]) Contains(val T) bool

Contains 判断集合是否包含某个值

func (*Set[T]) Empty

func (s *Set[T]) Empty() bool

Empty 判断集合是否为空

func (*Set[T]) Iter

func (s *Set[T]) Iter() iter.Seq[T]

Iter 集合迭代器

func (*Set[T]) Push

func (s *Set[T]) Push(val T)

Push 添加值到集合中

func (*Set[T]) Remove

func (s *Set[T]) Remove(val T)

Remove 从集合中移除某个值

func (*Set[T]) Size

func (s *Set[T]) Size() int

Size 获取集合大小

func (*Set[T]) Value

func (s *Set[T]) Value() []T

Value 获取集合的值

type ShardLruCache added in v0.0.5

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

ShardLruCache Lru 缓存 分片模式

func NewShardLruCache added in v0.0.5

func NewShardLruCache[T any](bucketCnt int, bucketCapacity int, expiration time.Duration) *ShardLruCache[T]

NewShardLruCache 构造函数 创建 lru 缓存

func (*ShardLruCache[T]) Get added in v0.0.5

func (lru *ShardLruCache[T]) Get(key string) (T, bool)

Get 从缓存获取

func (*ShardLruCache[T]) Put added in v0.0.5

func (lru *ShardLruCache[T]) Put(key string, val T)

Put 添加到缓存

func (*ShardLruCache[T]) Remove added in v0.0.5

func (lru *ShardLruCache[T]) Remove(key string)

Remove 移除缓存

func (*ShardLruCache[T]) SetHashFunc added in v0.0.5

func (lru *ShardLruCache[T]) SetHashFunc(fn func(string) int)

SetHashFunc 设置哈希函数

type SortedMap

type SortedMap[K cmp.Ordered, V any] struct {
	// contains filtered or unexported fields
}

SortedMap 有序Map

func NewSortedMap

func NewSortedMap[K cmp.Ordered, V any]() *SortedMap[K, V]

NewSortedMap 构造函数

func (*SortedMap[K, V]) Begin

func (s *SortedMap[K, V]) Begin() *KeyElement[K]

Begin 获取第一个元素

func (*SortedMap[K, V]) Clear

func (s *SortedMap[K, V]) Clear()

Clear 清空所有元素

func (*SortedMap[K, V]) Delete

func (s *SortedMap[K, V]) Delete(key K)

Delete 删除某个元素

func (*SortedMap[K, V]) Exist

func (s *SortedMap[K, V]) Exist(key K) bool

Exist 判断key释放存在

func (*SortedMap[K, V]) Find

func (s *SortedMap[K, V]) Find(key K) *KeyElement[K]

Find 找到某个Key的位置

func (*SortedMap[K, V]) Get

func (s *SortedMap[K, V]) Get(key K) V

Get 获取map元素

func (*SortedMap[K, V]) Insert

func (s *SortedMap[K, V]) Insert(key K, val V)

Insert 插入元素

func (*SortedMap[K, V]) MapElements

func (s *SortedMap[K, V]) MapElements() map[K]V

MapElements 获取所有的元素

func (*SortedMap[K, V]) Size

func (s *SortedMap[K, V]) Size() int

Size 获取元素个数

Jump to

Keyboard shortcuts

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