kind

package
v2.0.15 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2024 License: MIT Imports: 8 Imported by: 0

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 JsonParam added in v2.0.9

type JsonParam map[string]any

func (JsonParam) Exists added in v2.0.9

func (jp JsonParam) Exists(key string) bool

Exists key是否存在,返回bool值

func (JsonParam) Float64 added in v2.0.9

func (jp JsonParam) Float64(key string) float64

Float64 获取float64,如果不是float64,返回0

func (JsonParam) Int added in v2.0.9

func (jp JsonParam) Int(key string) int

Int 获取Int,如果不是int,返回0

func (JsonParam) Int64 added in v2.0.9

func (jp JsonParam) Int64(key string) int64

Int64 获取Int64,如果不是float64,返回0

func (JsonParam) Int64Slice added in v2.0.9

func (jp JsonParam) Int64Slice(key string) []int64

Int64Slice 获取[]int64,获取失败返回nil

func (JsonParam) IntSlice added in v2.0.9

func (jp JsonParam) IntSlice(key string) []int

IntSlice 获取[]int,获取失败,返回nil

func (JsonParam) String added in v2.0.9

func (jp JsonParam) String(key string) string

String 获取string值,如果不是string类型,返回""

func (JsonParam) StringSlice added in v2.0.9

func (jp JsonParam) StringSlice(key string) []string

StringSlice 获取[]string,如果不是[]string返回nil

func (JsonParam) Uint32Slice added in v2.0.9

func (jp JsonParam) Uint32Slice(key string) []uint32

Uint32Slice 获取[]uint32,获取失败返回nil

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
	Range(handler func(key K, value any) bool) bool
}

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
	// Range 按照分片遍历元素
	Range(handler func(key K, value any) bool)
}

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