hashmap

package
v0.0.0-...-48d2a37 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Map

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

Map is a hashmap. Like map[string]interface{}

func New

func New[K comparable, V any](cap int) *Map[K, V]

New returns a new Map. Like map[string]interface{}

func (*Map[K, V]) All

func (m *Map[K, V]) All() iter.Seq2[K, V]

All returns an iterator over all key/values. This is a replacement for Scan using the new iter package. It's not safe to call or Set or Delete while scanning.

func (*Map[K, V]) Copy

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

Copy the hashmap.

func (*Map[K, V]) Delete

func (m *Map[K, V]) Delete(key K) (prev V, deleted bool)

Delete deletes a value for a key. Returns the deleted value, or false when no value was assigned.

func (*Map[K, V]) Get

func (m *Map[K, V]) Get(key K) (value V, ok bool)

Get returns a value for a key. Returns false when no value has been assign for key.

func (*Map[K, V]) GetPos

func (m *Map[K, V]) GetPos(pos uint64) (key K, value V, ok bool)

GetPos gets a single keys/value nearby a position. The pos param can be any valid uint64. Useful for grabbing a random item from the map.

func (*Map[K, V]) Keys

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

Keys returns all keys as a slice

func (*Map[K, V]) Len

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

Len returns the number of values in map.

func (*Map[K, V]) Set

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

Set assigns a value to a key. Returns the previous value, or false when no value was assigned.

func (*Map[K, V]) Values

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

Values returns all values as a slice

Jump to

Keyboard shortcuts

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