hashmap

package
v0.0.0-...-a261c41 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2023 License: Apache-2.0 Imports: 4 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HashMap

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

func NewHashMap

func NewHashMap[T comparable, V comparable]() *HashMap[T, V]

创建一个新的哈希表

func (*HashMap[T, V]) Clear

func (h *HashMap[T, V]) Clear()

清空哈希表中的所有元素

func (*HashMap[T, V]) Delete

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

删除哈希表中指定键的键值对

func (*HashMap[T, V]) ForEach

func (h *HashMap[T, V]) ForEach(fn func(key T, value V))

遍历哈希表中的所有元素,并对每个元素执行指定的操作

func (*HashMap[T, V]) Get

func (h *HashMap[T, V]) Get(key T) (V, bool)

根据键获取哈希表中对应的值

func (*HashMap[T, V]) IsEmpty

func (h *HashMap[T, V]) IsEmpty() bool

检查哈希表是否为空

func (*HashMap[T, V]) Put

func (h *HashMap[T, V]) Put(key T, value V)

将键值对添加到哈希表中

func (*HashMap[T, V]) Size

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

返回哈希表中元素的数量

func (*HashMap[T, V]) String

func (h *HashMap[T, V]) String() string

实现fmt.Stringer接口,将哈希表转换为字符串表示形式

Jump to

Keyboard shortcuts

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