maps
3 分钟阅读
注意
从go1.21.0开始才有该包。
概述
Package maps defines various functions useful with maps of any type.
maps包定义了各种类型映射的有用函数。
常量
This section is empty.
变量
This section is empty.
函数
func All <- go1.23.0
| |
All returns an iterator over key-value pairs from m. The iteration order is not specified and is not guaranteed to be the same from one call to the next.
All 返回一个迭代器,用于遍历 m 中的键值对。迭代顺序未指定,并且从一次调用到下一次调用可能不相同。
func Clone
| |
Clone returns a copy of m. This is a shallow clone: the new keys and values are set using ordinary assignment.
Clone返回m的副本。这是一个浅拷贝:新键和值使用普通赋值设置。
func Collect <- go1.23.0
| |
Collect collects key-value pairs from seq into a new map and returns it.
Collect 将 seq 中的键值对收集到一个新的 map 中并返回。
func Copy
| |
Copy copies all key/value pairs in src adding them to dst. When a key in src is already present in dst, the value in dst will be overwritten by the value associated with the key in src.
Copy函数将src中的所有键/值对复制到dst中。当src中的某个键已经存在于dst中时,dst中的值将被src中与该键关联的值覆盖。
func DeleteFunc
| |
DeleteFunc deletes any key/value pairs from m for which del returns true.
DeleteFunc函数从m中删除del返回true的任何键/值对。
DeleteFunc Example
| |
func Equal
| |
Equal reports whether two maps contain the same key/value pairs. Values are compared using ==.
Equal函数报告两个映射是否包含相同的键/值对。值使用==进行比较。
func EqualFunc
| |
EqualFunc is like Equal, but compares values using eq. Keys are still compared with ==.
EqualFunc函数类似于Equal函数,但使用eq比较值。键仍然使用==进行比较。
EqualFunc Example
| |
func Insert <- go1.23.0
| |
Insert adds the key-value pairs from seq to m. If a key in seq already exists in m, its value will be overwritten.
Insert 将 seq 中的键值对添加到 m 中。如果 seq 中的键已经存在于 m 中,则其值会被覆盖。
func Keys <- go1.23.0
| |
Keys returns an iterator over keys in m. The iteration order is not specified and is not guaranteed to be the same from one call to the next.
Keys 返回一个迭代器,用于遍历 m 中的键。迭代顺序未指定,并且从一次调用到下一次调用可能不相同。
func Values <- go1.23.0
| |
Values returns an iterator over values in m. The iteration order is not specified and is not guaranteed to be the same from one call to the next.
Values 返回一个迭代器,用于遍历 m 中的值。迭代顺序未指定,并且从一次调用到下一次调用可能不相同。
类型
This section is empty.