Documentation ¶
Index ¶
- type Map
- func (slf *Map[Key, Value]) Atom(handle func(m hash.Map[Key, Value]))
- func (slf *Map[Key, Value]) AtomGetSet(key Key, handle func(value Value, exist bool) (newValue Value, isSet bool))
- func (slf *Map[Key, Value]) Clear()
- func (slf *Map[Key, Value]) ClearHandle(handle func(key Key, value Value))
- func (slf *Map[Key, Value]) Delete(key Key)
- func (slf *Map[Key, Value]) DeleteExist(key Key) bool
- func (slf *Map[Key, Value]) DeleteGet(key Key) Value
- func (slf *Map[Key, Value]) DeleteGetExist(key Key) (Value, bool)
- func (slf *Map[Key, Value]) Exist(key Key) bool
- func (slf *Map[Key, Value]) Get(key Key) Value
- func (slf *Map[Key, Value]) GetExist(key Key) (Value, bool)
- func (slf *Map[Key, Value]) GetOne() (value Value)
- func (slf *Map[Key, Value]) Keys() []Key
- func (slf *Map[Key, Value]) Map() map[Key]Value
- func (slf *Map[Key, Value]) MarshalJSON() ([]byte, error)
- func (slf *Map[Key, Value]) Range(handle func(key Key, value Value))
- func (slf *Map[Key, Value]) RangeBreakout(handle func(key Key, value Value) bool)
- func (slf *Map[Key, Value]) RangeFree(handle func(key Key, value Value, skip func(), breakout func()))
- func (slf *Map[Key, Value]) RangeSkip(handle func(key Key, value Value) bool)
- func (slf *Map[Key, Value]) Set(key Key, value Value)
- func (slf *Map[Key, Value]) Size() int
- func (slf *Map[Key, Value]) Slice() []Value
- func (slf *Map[Key, Value]) UnmarshalJSON(bytes []byte) error
- type MapOption
- type MapSegment
- func (slf *MapSegment[Key, Value]) Atom(handle func(m hash.Map[Key, Value]))
- func (slf *MapSegment[Key, Value]) AtomGetSet(key Key, handle func(value Value, exist bool) (newValue Value, isSet bool))
- func (slf *MapSegment[Key, Value]) Clear()
- func (slf *MapSegment[Key, Value]) ClearHandle(handle func(key Key, value Value))
- func (slf *MapSegment[Key, Value]) Delete(key Key)
- func (slf *MapSegment[Key, Value]) DeleteExist(key Key) bool
- func (slf *MapSegment[Key, Value]) DeleteGet(key Key) (value Value)
- func (slf *MapSegment[Key, Value]) DeleteGetExist(key Key) (value Value, exist bool)
- func (slf *MapSegment[Key, Value]) Exist(key Key) bool
- func (slf *MapSegment[Key, Value]) Get(key Key) (value Value)
- func (slf *MapSegment[Key, Value]) GetExist(key Key) (value Value, exist bool)
- func (slf *MapSegment[Key, Value]) GetOne() (value Value)
- func (slf *MapSegment[Key, Value]) Keys() []Key
- func (slf *MapSegment[Key, Value]) Map() map[Key]Value
- func (slf *MapSegment[Key, Value]) MarshalJSON() ([]byte, error)
- func (slf *MapSegment[Key, Value]) Range(handle func(key Key, value Value))
- func (slf *MapSegment[Key, Value]) RangeBreakout(handle func(key Key, value Value) bool)
- func (slf *MapSegment[Key, Value]) RangeFree(handle func(key Key, value Value, skip func(), breakout func()))
- func (slf *MapSegment[Key, Value]) RangeSkip(handle func(key Key, value Value) bool)
- func (slf *MapSegment[Key, Value]) Set(key Key, value Value)
- func (slf *MapSegment[Key, Value]) Size() int
- func (slf *MapSegment[Key, Value]) Slice() []Value
- func (slf *MapSegment[Key, Value]) UnmarshalJSON(bytes []byte) error
- type Pool
- type Slice
- type SliceOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Map ¶
type Map[Key comparable, Value any] struct { // contains filtered or unexported fields }
Map 并发安全的字典数据结构
func NewMap ¶
func NewMap[Key comparable, value any](options ...MapOption[Key, value]) *Map[Key, value]
func (*Map[Key, Value]) AtomGetSet ¶
func (slf *Map[Key, Value]) AtomGetSet(key Key, handle func(value Value, exist bool) (newValue Value, isSet bool))
AtomGetSet 原子方式获取一个值并在之后进行赋值
func (*Map[Key, Value]) ClearHandle ¶
func (slf *Map[Key, Value]) ClearHandle(handle func(key Key, value Value))
func (*Map[Key, Value]) DeleteExist ¶
func (*Map[Key, Value]) DeleteGetExist ¶
func (*Map[Key, Value]) MarshalJSON ¶
func (*Map[Key, Value]) Range ¶
func (slf *Map[Key, Value]) Range(handle func(key Key, value Value))
func (*Map[Key, Value]) RangeBreakout ¶
func (*Map[Key, Value]) RangeFree ¶
func (slf *Map[Key, Value]) RangeFree(handle func(key Key, value Value, skip func(), breakout func()))
func (*Map[Key, Value]) UnmarshalJSON ¶
type MapOption ¶ added in v0.0.15
type MapOption[Key comparable, Value any] func(m *Map[Key, Value])
func WithMapSource ¶ added in v0.0.15
func WithMapSource[Key comparable, Value any](source map[Key]Value) MapOption[Key, Value]
WithMapSource 通过传入的 map 初始化
type MapSegment ¶
type MapSegment[Key comparable, Value any] struct { // contains filtered or unexported fields }
MapSegment 基于分段锁实现的并发安全的字典数据结构map
func NewMapSegment ¶
func NewMapSegment[Key comparable, value any](segmentCount int) *MapSegment[Key, value]
func (*MapSegment[Key, Value]) Atom ¶
func (slf *MapSegment[Key, Value]) Atom(handle func(m hash.Map[Key, Value]))
func (*MapSegment[Key, Value]) AtomGetSet ¶
func (slf *MapSegment[Key, Value]) AtomGetSet(key Key, handle func(value Value, exist bool) (newValue Value, isSet bool))
AtomGetSet 原子方式获取一个值并在之后进行赋值
func (*MapSegment[Key, Value]) Clear ¶
func (slf *MapSegment[Key, Value]) Clear()
func (*MapSegment[Key, Value]) ClearHandle ¶
func (slf *MapSegment[Key, Value]) ClearHandle(handle func(key Key, value Value))
func (*MapSegment[Key, Value]) Delete ¶
func (slf *MapSegment[Key, Value]) Delete(key Key)
func (*MapSegment[Key, Value]) DeleteExist ¶
func (slf *MapSegment[Key, Value]) DeleteExist(key Key) bool
func (*MapSegment[Key, Value]) DeleteGet ¶
func (slf *MapSegment[Key, Value]) DeleteGet(key Key) (value Value)
func (*MapSegment[Key, Value]) DeleteGetExist ¶
func (slf *MapSegment[Key, Value]) DeleteGetExist(key Key) (value Value, exist bool)
func (*MapSegment[Key, Value]) Exist ¶
func (slf *MapSegment[Key, Value]) Exist(key Key) bool
func (*MapSegment[Key, Value]) Get ¶
func (slf *MapSegment[Key, Value]) Get(key Key) (value Value)
func (*MapSegment[Key, Value]) GetExist ¶
func (slf *MapSegment[Key, Value]) GetExist(key Key) (value Value, exist bool)
func (*MapSegment[Key, Value]) GetOne ¶
func (slf *MapSegment[Key, Value]) GetOne() (value Value)
GetOne 获取一个
func (*MapSegment[Key, Value]) Keys ¶
func (slf *MapSegment[Key, Value]) Keys() []Key
func (*MapSegment[Key, Value]) Map ¶
func (slf *MapSegment[Key, Value]) Map() map[Key]Value
func (*MapSegment[Key, Value]) MarshalJSON ¶
func (slf *MapSegment[Key, Value]) MarshalJSON() ([]byte, error)
func (*MapSegment[Key, Value]) Range ¶
func (slf *MapSegment[Key, Value]) Range(handle func(key Key, value Value))
func (*MapSegment[Key, Value]) RangeBreakout ¶
func (slf *MapSegment[Key, Value]) RangeBreakout(handle func(key Key, value Value) bool)
func (*MapSegment[Key, Value]) RangeFree ¶
func (slf *MapSegment[Key, Value]) RangeFree(handle func(key Key, value Value, skip func(), breakout func()))
func (*MapSegment[Key, Value]) RangeSkip ¶
func (slf *MapSegment[Key, Value]) RangeSkip(handle func(key Key, value Value) bool)
func (*MapSegment[Key, Value]) Set ¶
func (slf *MapSegment[Key, Value]) Set(key Key, value Value)
func (*MapSegment[Key, Value]) Size ¶
func (slf *MapSegment[Key, Value]) Size() int
func (*MapSegment[Key, Value]) Slice ¶
func (slf *MapSegment[Key, Value]) Slice() []Value
func (*MapSegment[Key, Value]) UnmarshalJSON ¶
func (slf *MapSegment[Key, Value]) UnmarshalJSON(bytes []byte) error
type Pool ¶
type Pool[T any] struct { // contains filtered or unexported fields }
Pool 线程安全的对象缓冲池
- 一些高频临时生成使用的对象可以通过 Pool 进行管理,例如属性计算等
- 缓冲区内存在可用对象时直接返回,否则新建一个进行返回
- 通过 Release 将使用完成的对象放回缓冲区,超出缓冲区大小的对象将被放弃
type Slice ¶
type Slice[T any] struct { // contains filtered or unexported fields }
func NewSlice ¶
func NewSlice[T any](options ...SliceOption[T]) *Slice[T]
func (*Slice[T]) GetWithRange ¶
type SliceOption ¶
func WithSliceCap ¶
func WithSliceCap[T any](cap int) SliceOption[T]
func WithSliceLen ¶
func WithSliceLen[T any](len int) SliceOption[T]
func WithSliceLenCap ¶
func WithSliceLenCap[T any](len, cap int) SliceOption[T]
Click to show internal directories.
Click to hide internal directories.