fastmap

package module
v0.0.0-...-705e323 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HashMap

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

func New

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

New initializes new HashMap with default map size.

func (*HashMap[K, V]) Delete

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

Delete deletes a value from the map with given key.

func (*HashMap[K, V]) Get

func (m *HashMap[K, V]) Get(key K) (V, bool)

Get returns an element from the map with given key.

func (*HashMap[K, V]) Insert

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

Insert inserts a value to the map with given key. Insert also checks if the buckets are need to grow by load factor threshold. If is that, buckets will be re-hashed and re-filled.

func (*HashMap[K, V]) Len

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

Len returns the number of elements within the map.

func (*HashMap[K, V]) SetHashf

func (m *HashMap[K, V]) SetHashf(f func(key K) uintptr)

SetHashf sets the provided hash function instead of standart.

func (*HashMap[K, V]) SetIndexf

func (m *HashMap[K, V]) SetIndexf(f func(hash uintptr) uintptr)

SetIndexf sets the provided index function instead of standart.

type Hashable

type Hashable interface {
	constraints.Signed | constraints.Unsigned | constraints.Float | ~uintptr | ~string
}

Jump to

Keyboard shortcuts

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