hashmap

package
v0.0.0-...-fc5f66e Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2023 License: BSD-2-Clause Imports: 4 Imported by: 0

Documentation

Overview

Package hashmap implements a map backed by a hash table.

Elements are unordered in the map.

Structure is not thread safe.

Reference: http://en.wikipedia.org/wiki/Associative_array

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Map

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

Map holds the elements in go's native map

func New

func New[K cmp.Ordered, V any]() *Map[K, V]

New instantiates a hash map.

func NewWith

func NewWith[K, V any](comparator utils.CompareFunc[K]) *Map[K, V]

NewWith instantiates a hash map with key comparator.

func (*Map[K, V]) Clear

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

Clear removes all elements from the map.

func (*Map[K, V]) Empty

func (m *Map[K, V]) Empty() bool

Empty returns true if map does not contain any elements

func (*Map[K, V]) Get

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

Get searches the element in the map by key and returns its value or nil if key is not found in map. Second return parameter is true if key was found, otherwise false.

func (*Map[K, V]) Keys

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

Keys returns all keys (random order).

func (*Map[K, V]) Put

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

Put inserts element into the map.

func (*Map[K, V]) Remove

func (m *Map[K, V]) Remove(key K)

Remove removes the element from the map by key.

func (*Map[K, V]) Size

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

Size returns number of elements in the map.

func (*Map[K, V]) String

func (m *Map[K, V]) String() string

String returns a string representation of container

func (*Map[K, V]) Values

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

Values returns all values (random order).

Jump to

Keyboard shortcuts

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