Documentation
¶
Index ¶
- type ArrayStack
- type Cache
- type CacheOpt
- type DestroyFunc
- type HashSet
- func (s HashSet[T]) Append(items ...T)
- func (s HashSet[T]) Contains(value T) (exist bool)
- func (s HashSet[T]) Difference(s1 Set[T]) Set[T]
- func (s HashSet[T]) Intersection(s1 Set[T]) Set[T]
- func (s HashSet[T]) Len() int
- func (s HashSet[T]) Remove(values ...T) bool
- func (s HashSet[T]) String() string
- func (s HashSet[T]) SymmetricDifference(s1 Set[T]) Set[T]
- func (s HashSet[T]) Union(s1 Set[T]) Set[T]
- func (s HashSet[T]) Values() (values []T)
- type IDFunc
- type LinkStack
- type Map
- type MutexMap
- func (m *MutexMap[K, V]) CompareAndDelete(key K, old V) bool
- func (m *MutexMap[K, V]) CompareAndSwap(key K, old, new V) bool
- func (m *MutexMap[K, V]) CompareFnAndDelete(key K, fn func(V, V) bool, old V) bool
- func (m *MutexMap[K, V]) CompareFnAndSwap(key K, fn func(V, V) bool, old, new V) bool
- func (m *MutexMap[K, V]) Delete(key K) bool
- func (m *MutexMap[K, V]) Load(key K) (value V, ok bool)
- func (m *MutexMap[K, V]) LoadAndDelete(key K) (value V, loaded bool)
- func (m *MutexMap[K, V]) LoadOrStore(key K, new V) (actual V, loaded bool)
- func (m *MutexMap[K, V]) Range(iterator func(key K, value V) bool)
- func (m *MutexMap[K, V]) Store(key K, value V)
- func (m *MutexMap[K, V]) Swap(key K, value V) (pre V, loaded bool)
- type NewFunc
- type Pool
- type Set
- type Stack
- type SyncMap
- func (m *SyncMap[K, V]) CompareAndDelete(key K, old V) bool
- func (m *SyncMap[K, V]) CompareAndSwap(key K, old, new V) bool
- func (m *SyncMap[K, V]) CompareFnAndDelete(key K, fn func(V, V) bool, old V) bool
- func (m *SyncMap[K, V]) CompareFnAndSwap(key K, fn func(V, V) bool, old, new V) bool
- func (m *SyncMap[K, V]) Delete(key K) bool
- func (m *SyncMap[K, V]) Load(key K) (value V, ok bool)
- func (m *SyncMap[K, V]) LoadAndDelete(key K) (value V, loaded bool)
- func (m *SyncMap[K, V]) LoadOrStore(key K, new V) (actual V, loaded bool)
- func (m *SyncMap[K, V]) Range(iterator func(key K, value V) bool)
- func (m *SyncMap[K, V]) Store(key K, value V)
- func (m *SyncMap[K, V]) Swap(key K, value V) (pre V, loaded bool)
- type SyncSet
- func (s *SyncSet[T]) Append(values ...T)
- func (s *SyncSet[T]) Contains(v T) bool
- func (s *SyncSet[T]) Difference(s1 Set[T]) Set[T]
- func (s *SyncSet[T]) Intersection(s1 Set[T]) Set[T]
- func (s *SyncSet[T]) Len() int
- func (s *SyncSet[T]) Remove(values ...T) bool
- func (s *SyncSet[T]) String() string
- func (s *SyncSet[T]) SymmetricDifference(s1 Set[T]) Set[T]
- func (s *SyncSet[T]) Union(s1 Set[T]) Set[T]
- func (s *SyncSet[T]) Values() []T
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ArrayStack ¶
type ArrayStack[T any] struct { // contains filtered or unexported fields }
func NewArrayStack ¶
func NewArrayStack[T any]() *ArrayStack[T]
func (*ArrayStack[T]) Empty ¶
func (m *ArrayStack[T]) Empty() bool
func (*ArrayStack[T]) Peek ¶
func (m *ArrayStack[T]) Peek() (value T, exist bool)
func (*ArrayStack[T]) Pop ¶
func (m *ArrayStack[T]) Pop() (value T, exist bool)
func (*ArrayStack[T]) Push ¶
func (m *ArrayStack[T]) Push(value T)
func (*ArrayStack[T]) Size ¶
func (m *ArrayStack[T]) Size() int
func (*ArrayStack[T]) String ¶
func (m *ArrayStack[T]) String() string
type HashSet ¶
type HashSet[T comparable] map[T]struct{}
func NewHashSet ¶
func NewHashSet[T comparable](items ...T) HashSet[T]
Create a new Set with element type T
func (HashSet[T]) Difference ¶
Difference 返回两个集合的对称差集
func (HashSet[T]) Intersection ¶
Intersection 返回两个集合的交集
func (HashSet[T]) SymmetricDifference ¶
Difference 返回两个集合的差集
type LinkStack ¶
type LinkStack[T any] struct { // contains filtered or unexported fields }
func NewLinkStack ¶
type Map ¶
type Map[K comparable, V any] interface { // 存储 Store(K, V) // 读取 Load(K) (V, bool) // 删除 Delete(K) bool // 交换 Swap(key K, newValue V) (old V, loaded bool) // 遍历,当iterator返回false时,遍历终止 Range(iterator func(K, V) bool) // 读取或将值存储 LoadOrStore(key K, newValue V) (value V, loaded bool) // 读取并删除 LoadAndDelete(K) (value V, loaded bool) // 对比并交换 // 对比当前map中key对应的value是否等于old,如果相等则将key对应的value替换为newValue CompareAndSwap(key K, old, newValue V) bool // 对比并删除 // 对比当前map中key对应的value是否等于value,如果相等则删除 CompareAndDelete(key K, value V) bool CompareFnAndSwap(key K, fn func(V, V) bool, old, newValue V) bool CompareFnAndDelete(key K, fn func(V, V) bool, old V) bool }
type MutexMap ¶
type MutexMap[K comparable, V any] struct { // contains filtered or unexported fields }
func NewMutexMap ¶
func NewMutexMap[K comparable, V any]() *MutexMap[K, V]
func (*MutexMap[K, V]) CompareAndDelete ¶
func (*MutexMap[K, V]) CompareAndSwap ¶
func (*MutexMap[K, V]) CompareFnAndDelete ¶
func (*MutexMap[K, V]) CompareFnAndSwap ¶
func (*MutexMap[K, V]) LoadAndDelete ¶
func (*MutexMap[K, V]) LoadOrStore ¶
type Pool ¶
type Pool[K, V any] struct { New NewFunc[K, V] Identifier IDFunc[K] Destroy DestroyFunc[V] // contains filtered or unexported fields }
func (*Pool[K, V]) GetWithCtx ¶
func (*Pool[K, V]) PutWithCtx ¶
type Set ¶
type Set[T comparable] interface { fmt.Stringer // 集合长度 Len() int // 添加元素 Append(...T) // 移除元素 Remove(...T) bool // 判断元素是否存在 Contains(T) bool // 集合元素的切片 Values() []T // 并集 Union(Set[T]) Set[T] // 交集 Intersection(Set[T]) Set[T] // 差集 Difference(Set[T]) Set[T] // 对称差集 SymmetricDifference(Set[T]) Set[T] }
type SyncMap ¶
type SyncMap[K comparable, V any] struct { // contains filtered or unexported fields }
Generic wrapper for sync.Map
func NewSyncMap ¶
func NewSyncMap[K comparable, V any]() *SyncMap[K, V]
func (*SyncMap[K, V]) CompareAndDelete ¶
func (*SyncMap[K, V]) CompareAndSwap ¶
func (*SyncMap[K, V]) CompareFnAndDelete ¶
func (*SyncMap[K, V]) CompareFnAndSwap ¶
func (*SyncMap[K, V]) LoadAndDelete ¶
func (*SyncMap[K, V]) LoadOrStore ¶
type SyncSet ¶
type SyncSet[T comparable] struct { // contains filtered or unexported fields }
func NewSyncSet ¶
func NewSyncSet[T comparable](items ...T) *SyncSet[T]
Create a new Set with element type T
func (*SyncSet[T]) SymmetricDifference ¶
对称差集
Click to show internal directories.
Click to hide internal directories.