util

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: May 8, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StringDS = iota
	CounterDS
	ObjectDS
	ListDS
	ZListDS
	SetDS
	BitmapDS
	BloomFilterDS
	LockDS
)

Variables

This section is empty.

Functions

func BytesToInt

func BytesToInt(b []byte) int

func BytesToInt64

func BytesToInt64(b []byte) int64

func GetRealSizeOf added in v0.0.7

func GetRealSizeOf(data interface{}) int

func Int64ToBytes

func Int64ToBytes(n int64) []byte

func IntToBytes

func IntToBytes(n int) []byte

func Next2Power

func Next2Power(num uint) uint

func SetIfHitLimit

func SetIfHitLimit(param int, min int, max int) int

Types

type Bitmap

type Bitmap struct {
	// contains filtered or unexported fields
}

func NewBitmap

func NewBitmap() *Bitmap

func NewBitmapWithCap

func NewBitmapWithCap(cap uint64) *Bitmap

NewBitmapWithCap cap's unit is [bit]

func (*Bitmap) BitCount

func (bitmap *Bitmap) BitCount(start int, end int) int

func (*Bitmap) Cap

func (bitmap *Bitmap) Cap() int

func (*Bitmap) Clear

func (bitmap *Bitmap) Clear(num int)

func (*Bitmap) Has

func (bitmap *Bitmap) Has(num int) bool

func (*Bitmap) Len

func (bitmap *Bitmap) Len() int

func (*Bitmap) MemoryUsage added in v0.0.7

func (bitmap *Bitmap) MemoryUsage() int

func (*Bitmap) Set

func (bitmap *Bitmap) Set(num int)

func (*Bitmap) String

func (bitmap *Bitmap) String() string

func (*Bitmap) Value

func (bitmap *Bitmap) Value() []uint64

type BloomFilter

type BloomFilter struct {
	// contains filtered or unexported fields
}

func NewBloomFilter

func NewBloomFilter(m, k uint64) *BloomFilter

func NewBloomFilterByView

func NewBloomFilterByView(view *BloomView) *BloomFilter

func NewBloomFilterWithEstimates

func NewBloomFilterWithEstimates(n uint, fp float64) *BloomFilter

func (*BloomFilter) Add

func (f *BloomFilter) Add(data string)

func (*BloomFilter) ClearAll

func (f *BloomFilter) ClearAll() *BloomFilter

func (*BloomFilter) EstimateFalsePositiveRate

func (f *BloomFilter) EstimateFalsePositiveRate(n uint) (fpRate float64)

func (*BloomFilter) MemoryUsage added in v0.0.7

func (f *BloomFilter) MemoryUsage() int

func (*BloomFilter) Size

func (f *BloomFilter) Size() uint64

func (*BloomFilter) Test

func (f *BloomFilter) Test(data string) bool

Test check if data exists

func (*BloomFilter) Value

func (f *BloomFilter) Value() *BloomView

type BloomView

type BloomView struct {
	N   uint64
	M   uint64
	K   uint64
	Mem []uint64
}

type DSType

type DSType uint8

type Set

type Set struct {
	// contains filtered or unexported fields
}

func NewSet

func NewSet(list []interface{}) *Set

func (*Set) Add

func (s *Set) Add(e interface{})

func (*Set) Contains

func (s *Set) Contains(e interface{}) bool

func (*Set) Diff

func (s *Set) Diff(another *Set) *Set

func (*Set) Get

func (s *Set) Get() []interface{}

func (*Set) Intersect

func (s *Set) Intersect(another *Set) *Set

func (*Set) Remove

func (s *Set) Remove(e interface{})

func (*Set) Size

func (s *Set) Size() int

func (*Set) Union

func (s *Set) Union(another *Set) *Set

type SkipList

type SkipList struct {
	// contains filtered or unexported fields
}

func NewSkipList

func NewSkipList() *SkipList

func (*SkipList) Delete

func (sl *SkipList) Delete(score float64)

func (*SkipList) Front

func (sl *SkipList) Front() *slNode

func (*SkipList) GetList

func (sl *SkipList) GetList() []SlElement

func (*SkipList) Insert

func (sl *SkipList) Insert(score float64, value interface{}) *slNode

func (*SkipList) Len

func (sl *SkipList) Len() int

func (*SkipList) Search

func (sl *SkipList) Search(score float64) ([]*slNode, bool)

type SlElement

type SlElement struct {
	Score float64     `json:"score"`
	Val   interface{} `json:"val"`
}

Jump to

Keyboard shortcuts

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