standard

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrSize = errors.New("maxSize can't be less than minSize")
)

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) (any, 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]) 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]) Pop

func (q *Queue[T]) Pop() any

弹出

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 comparable] struct {
	// contains filtered or unexported fields
}

不重复切片

func NewSet

func NewSet[T comparable]() *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]) Has

func (s *Set[T]) Has(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

Jump to

Keyboard shortcuts

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