HashMap

package
v0.0.0-...-de9bdf8 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewBucket

func NewBucket[K Hashable, V any]() *bucket[K, V]

initialize new bucket

func NewNode

func NewNode[K Hashable, V any](key K, value V) *node[K, V]

initialize new node

Types

type HashMap

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

func NewHashMap

func NewHashMap[K Hashable, V any](size int, maxLoadFactor float64) *HashMap[K, V]

initialize new HashMap

func (*HashMap[K, V]) Count

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

Get count of items in hashmap

func (*HashMap[K, V]) Delete

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

Delete - Remove items from hashmap

func (*HashMap[K, V]) Get

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

Get items from hashmap

func (*HashMap[K, V]) LoadFactor

func (h *HashMap[K, V]) LoadFactor() float64

Get load factor of hashmap

func (*HashMap[K, V]) Reset

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

Reset - Clear hashmap

func (*HashMap[K, V]) Resize

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

Resize hashmap

func (*HashMap[K, V]) Set

func (h *HashMap[K, V]) Set(key K, value V) error

Set - Add items to hashmap or update items in hashmap

func (*HashMap[K, V]) SetLoadFactor

func (h *HashMap[K, V]) SetLoadFactor(loadFactor float64)

Set load factor of hashmap (default is 0.75)

func (*HashMap[K, V]) Size

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

Get size of hashmap

type Hashable

type Hashable interface {
	~int | ~int8 | ~int16 | ~int32 | ~int64 | ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr | ~float32 | ~float64 | ~string
}

Jump to

Keyboard shortcuts

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