rhashmap

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HT_INITIAL_EXP  = 2
	HT_INITIAL_SIZE = (1 << (HT_INITIAL_EXP))
)

Variables

View Source
var (
	ErrHashing  = errors.New("rehashing...")
	ErrSize     = errors.New("wrong size")
	ErrNotFound = errors.New("not found")
)

Functions

This section is empty.

Types

type HashMap

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

hash 表头

func New

func New[K comparable, V any]() *HashMap[K, V]

初始化一个hashtable

func NewWithOpt

func NewWithOpt[K comparable, V any](opts ...Option) *HashMap[K, V]

初始化一个hashtable并且可以设置值

func (*HashMap[K, V]) Delete

func (h *HashMap[K, V]) Delete(key K)

Remove是delete别名

func (*HashMap[K, V]) Get

func (h *HashMap[K, V]) Get(key K) (v V)

获取

func (*HashMap[K, V]) GetWithBool added in v0.0.6

func (h *HashMap[K, V]) GetWithBool(key K) (v V, ok bool)

获取

func (*HashMap[K, V]) Init

func (h *HashMap[K, V]) Init()

func (*HashMap[K, V]) Len

func (h *HashMap[K, V]) Len() int

测试长度

func (*HashMap[K, V]) Range

func (h *HashMap[K, V]) Range(pr func(key K, val V) bool)

遍历

func (*HashMap[K, V]) Remove

func (h *HashMap[K, V]) Remove(key K) (err error)

删除

func (*HashMap[K, V]) Resize

func (h *HashMap[K, V]) Resize(size uint64) error

手动修改hashtable的大小

func (*HashMap[K, V]) Set

func (h *HashMap[K, V]) Set(k K, v V)

func (*HashMap[K, V]) SetWithPrev

func (h *HashMap[K, V]) SetWithPrev(k K, v V) (prev V, replaced bool)

设置

func (*HashMap[K, V]) ShrinkToFit

func (h *HashMap[K, V]) ShrinkToFit() error

收缩hash table

type Option

type Option interface {
	// contains filtered or unexported methods
}

apache 2.0 antlabs

func WithCap

func WithCap(cap int) Option

func WithHashFunc

func WithHashFunc(hfunc func(str string) uint64) Option

Jump to

Keyboard shortcuts

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