From 57de5f8bbe84458aee1ecbd2a11f0b5eb67fab27 Mon Sep 17 00:00:00 2001 From: Coloured-glaze <1044187534@qq.com> Date: Sat, 7 Jan 2023 00:55:30 +0800 Subject: [PATCH] update --- README-en.md | 16 ++++++++++++++++ README.md | 6 +++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/README-en.md b/README-en.md index 04bee04..90bc07c 100644 --- a/README-en.md +++ b/README-en.md @@ -39,6 +39,22 @@ The package is now imported under the "cmap" namespace. ``` +```go + + // Create a new map. + m := cmap.New[map[string]int]() + + // Sets item within map, sets "bar" under key "foo" + m.Set("user", make(map[string]int)) + + // Retrieve item from map. + bar, ok := m.Get("user") + + // Removes item under key "foo" + m.Remove("user") + +``` + For more examples have a look at concurrent_map_test.go. Running tests: diff --git a/README.md b/README.md index 922baec..588232f 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ go get "github.com/Coloured-glaze/cmap" m := cmap.New[map[string]int]() // 设置变量m一个键为 "user" 值为 map[string]int 键值对 - m.Set("user", map[string]int) + m.Set("user", make(map[string]int)) // 从m中获取指定键值. v, ok := m.Get("user") @@ -70,5 +70,9 @@ go test "github.com/Coloured-glaze/cmap" - 如果代码是关于性能问题的,则必须在流程中包括基准测试(无论是在问题中还是在PR中)。 - 一般来说,我们希望`concurrent-map`尽可能简单,且与原生的`map`有相似的操作。当你新建issue时请注意这一点。 +## language +- [中文说明](./README.md) +- [English description](./README-en.md) + ## 许可证 MIT (see [LICENSE](https://github.com/Coloured-glaze/cmap/blob/master/LICENSE) file)