standard

package
v1.7.3 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrSize = errors.New("max size can't be less than min size")
)

Functions

This section is empty.

Types

type HashFunc

type HashFunc func(data []byte) uint32

type Hashing

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

func NewHashing

func NewHashing(replicas int, fn HashFunc) *Hashing

func (*Hashing) Add

func (h *Hashing) Add(keys ...string)

Add adds some keys to the hash.

func (*Hashing) Del

func (h *Hashing) Del(keys ...string)

func (*Hashing) Get

func (h *Hashing) Get(key string) string

Get gets the closest item in the hash to the provided key.

type Map added in v1.0.2

type Map[K comparable, V any] struct {
	// contains filtered or unexported fields
}

func NewMap added in v1.0.2

func NewMap[K comparable, V any]() Map[K, V]

func (*Map[K, V]) Clear added in v1.0.2

func (m *Map[K, V]) Clear()

func (*Map[K, V]) Erase added in v1.0.2

func (m *Map[K, V]) Erase(key K)

func (*Map[K, V]) Find added in v1.0.2

func (m *Map[K, V]) Find(key K) (V, bool)

func (*Map[K, V]) Insert added in v1.0.2

func (m *Map[K, V]) Insert(key K, value V)

func (*Map[K, V]) Range added in v1.0.4

func (m *Map[K, V]) Range(f func(key K, value V) bool)

func (*Map[K, V]) Size added in v1.0.2

func (m *Map[K, V]) Size() int

type Pool

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

Pool is actually multiple pools which store buffers of specific size. i.e. it can be three pools which return buffers 32K, 64K and 128K.

func NewBufferStore

func NewBufferStore(minSize, maxSize int) (*Pool, error)

New returns Pool which has buckets from minSize to maxSize. Buckets increase with the power of two, i.e with multiplier 2: [2b, 4b, 16b, ... , 1024b] Last pool will always be capped to maxSize.

func (*Pool) Get

func (p *Pool) Get(size int) *[]byte

Get returns pointer to []byte which has len size. If there is no bucket with buffers >= size, slice will be allocated.

func (*Pool) Put

func (p *Pool) Put(b *[]byte)

Put returns pointer to slice to some bucket. Discards slice for which there is no bucket

type Queue

type Queue[T any] struct {
	// contains filtered or unexported fields
}

多线程队列

func NewQueue

func NewQueue[T any]() *Queue[T]

func (*Queue[T]) Erase added in v1.5.0

func (q *Queue[T]) Erase()

删除头部

func (*Queue[T]) Front added in v1.5.0

func (q *Queue[T]) Front() (T, bool)

访问头部

func (*Queue[T]) Pop

func (q *Queue[T]) Pop() (T, bool)

弹出头部,并删除

func (*Queue[T]) Push

func (q *Queue[T]) Push(v T)

插入

func (*Queue[T]) Size

func (q *Queue[T]) Size() uint

type RingBuffer

type RingBuffer[T any] struct {
	// contains filtered or unexported fields
}

环形缓冲

func NewRingBuf

func NewRingBuf[T any](size int) *RingBuffer[T]

func (*RingBuffer[T]) IsFull

func (r *RingBuffer[T]) IsFull() bool

func (*RingBuffer[T]) Pop

func (r *RingBuffer[T]) Pop() T

出队

func (*RingBuffer[T]) Push

func (r *RingBuffer[T]) Push(data T) bool

入队

func (*RingBuffer[T]) Size

func (r *RingBuffer[T]) Size() int

实际容纳的数据量

type Set

type Set[T cmp.Ordered] struct {
	// contains filtered or unexported fields
}

不重复切片

func NewSet

func NewSet[T cmp.Ordered]() Set[T]

func (*Set[T]) Clear

func (s *Set[T]) Clear()

func (*Set[T]) Empty

func (s *Set[T]) Empty() bool

func (*Set[T]) Erase

func (s *Set[T]) Erase(key T)

func (*Set[T]) Exist added in v1.7.3

func (s *Set[T]) Exist(key T) bool

func (*Set[T]) Insert

func (s *Set[T]) Insert(key T)

func (*Set[T]) List

func (s *Set[T]) List() []T

func (*Set[T]) Size

func (s *Set[T]) Size() int

func (*Set[T]) SortList added in v1.7.3

func (s *Set[T]) SortList() []T

Jump to

Keyboard shortcuts

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