kind

package
v2.0.7 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2023 License: MIT Imports: 8 Imported by: 1

Documentation

Index

Constants

View Source
const (
	StateIndexMax = 30
)

Variables

View Source
var Empty = struct{}{}
View Source
var (
	ErrIndex = errors.New("index out of range")
)
View Source
var Uint32Hash = crc32.ChecksumIEEE

Functions

func KeyHash

func KeyHash(key interface{}) uint32

Types

type Bitmap

type Bitmap interface {
	// HasBit 是否有值
	HasBit() bool
	// BitCount 值的数量
	BitCount() int
	// Exists 标签是否存在
	Exists(tag int) (exists bool)
	// AddTag 添加标签
	AddTag(tag int) Bitmap
	// DelTag 删除标签
	DelTag(tag int) Bitmap
	// Data 原始数据
	Data() (data []byte)
	// SprinfBinary 二进制打印
	SprinfBinary() string
}

Bitmap bitmap数据结构

func NewBitmap

func NewBitmap(data []byte) Bitmap

type CanHash

type CanHash interface {
	// HashCode 计算hash值
	HashCode() (hashValue uint32)
}

CanHash hash接口

type Container

type Container[K comparable] interface {
	Set(key K, value any)
	Get(key K) (value any, exists bool)
}

func NewContainer

func NewContainer[K comparable]() Container[K]

type Float

type Float interface {
	~float32 | ~float64
}

type Int

type Int interface {
	~int8 | ~int16 | ~int32 | ~int | ~int64
}

type Integer

type Integer interface {
	Int | Uint
}

type Key

type Key interface {
	~string | Integer
}

type Map

type Map[K comparable, V any] map[K]V

type Number

type Number interface {
	Int | Uint | Float
}

type RedisValue added in v2.0.5

type RedisValue interface {
	Number | ~bool | ~string | ~[]byte
}

type Set

type Set[V comparable] interface {
	Add(value V) (isNew bool)
	Del(list ...V) (delNum int)
	Exists(value V) (exists bool)
	Length() (length int)
	List() (list Slice[V])
	Pop() (value V)
	Rand() (value V)
}

func NewConcurrentSet

func NewConcurrentSet[V comparable](initSize uint) Set[V]

func NewSet

func NewSet[V comparable](initSize uint) Set[V]

type Shard

type Shard[K Key] interface {
	Set(key K, value any) (oldValue any, exists bool)
	Get(key K) (value any, exists bool)
	Exists(key K) (exists bool)
	Delete(keys ...K) (delNum int)
	Length() int64
}

func NewShard

func NewShard[K Key](initSize int) Shard[K]

type ShardMap

type ShardMap[K Key] interface {
	// Set 存储
	Set(key K, value any) (isCreate bool)
	// Get 获取
	Get(key K) (value any, exists bool)
	// Exists 是否存在
	Exists(key K) (exists bool)
	// Delete 删除
	Delete(keys ...K) (delNum int)
	// Length 长度
	Length() int64
	// ShardLength 返回每个分片的长度,可以协助分析元素是否平均分配
	ShardLength() []int64
}

ShardMap 分片Map

func NewShardMap

func NewShardMap[K Key]() ShardMap[K]

NewShardMap 实例化ShardMap

type Slice

type Slice[T any] []T

type State

type State int32

func StateFromSlice

func StateFromSlice(list []uint8) (State, error)

func StatusFromValueSlice

func StatusFromValueSlice(list []int32) State

func (*State) Add

func (s *State) Add(indexList ...uint8) error

func (*State) Has

func (s *State) Has(index uint8) bool

func (*State) Intersection

func (s *State) Intersection(val State) []uint8

func (*State) Merge

func (s *State) Merge(val State)

func (*State) Remove

func (s *State) Remove(index uint8)

func (*State) RemoveAll

func (s *State) RemoveAll()

func (*State) Slice

func (s *State) Slice() []uint8

func (*State) UnionSet

func (s *State) UnionSet(val State) []uint8

func (*State) ValueSlice

func (s *State) ValueSlice() []int32

type Uint

type Uint interface {
	~uint8 | ~uint16 | ~uint32 | ~uint | ~uint64
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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