orderedmap:在 go 中使用的受保护和有序的地图

时间:2021-05-30 10:42:00
【文件属性】:
文件名称:orderedmap:在 go 中使用的受保护和有序的地图
文件大小:6KB
文件格式:ZIP
更新时间:2021-05-30 10:42:00
Go 有序映射 提供以特定顺序存储其项目的映射,该顺序可以以受保护和并发的方式使用。 映射键必须是字符串,但数据可以是任何东西。 用法 您首先需要制作一张新地图并添加一些数据。 使用 New() 函数创建一个新映射,然后使用 Set(Key, Val) 函数添加一些数据,该函数将键作为字符串,将任何数据类型作为值: om := orderedmap.New() om.Set("one", TestData{ID: 1, Name: "one"}) om.Set("two", TestData{ID: 2, Name: "two"}) om.Set("three", TestData{ID: 3, Name: "three"}) 您可以使用 GetKey 或 GetIndex 从地图中获取数据。 GetKey 使用键字符串提取数据,GetIndex 使用地图中的当前位置,按顺序。 data
【文件预览】:
orderedmap-master
----.gitignore(266B)
----orderedmap_test.go(6KB)
----LICENSE(1KB)
----orderedmap.go(7KB)
----README.md(1KB)

网友评论