1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-02-11 08:12:26 +08:00

doc: update document for maputil function

This commit is contained in:
dudaodong
2023-01-02 14:21:23 +08:00
parent 3712819994
commit 31fdbee0b5
3 changed files with 51 additions and 17 deletions

View File

@@ -400,14 +400,31 @@ import "github.com/duke-git/lancet/v2/maputil"
#### Function list: #### Function list:
- [ForEach](https://github.com/duke-git/lancet/blob/main/docs/maputil.md#ForEach) - **<big>ForEach</big>** : executes iteratee funcation for every key and value pair in map.
- [Filter](https://github.com/duke-git/lancet/blob/main/docs/maputil.md#Filter) [[doc](https://github.com/duke-git/lancet/blob/main/docs/maputil.md#ForEach)]
- [Intersect](https://github.com/duke-git/lancet/blob/main/docs/maputil.md#Intersect) [[play](https://go.dev/play/p/OaThj6iNVXK)]
- [Keys](https://github.com/duke-git/lancet/blob/main/docs/maputil.md#Keys) - **<big>Filter</big>** : iterates over map, return a new map contains all key and value pairs pass the predicate function.
- [Merge](https://github.com/duke-git/lancet/blob/main/docs/maputil.md#Merge) [[doc](https://github.com/duke-git/lancet/blob/main/docs/maputil.md#Filter)]
- [Minus](https://github.com/duke-git/lancet/blob/main/docs/maputil.md#Minus) [[play](https://go.dev/play/p/fSvF3wxuNG7)]
- [Values](https://github.com/duke-git/lancet/blob/main/docs/maputil.md#Values) - **<big>Intersect</big>** : iterates over maps, return a new map of key and value pairs in all given maps.
- [IsDisjoint](https://github.com/duke-git/lancet/blob/main/docs/maputil.md#IsDisjoint) [[doc](https://github.com/duke-git/lancet/blob/main/docs/maputil.md#Intersect)]
[[play](https://go.dev/play/p/Zld0oj3sjcC)]
- **<big>Keys</big>** : returns a slice of the map's keys.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/maputil.md#Keys)]
[[play](https://go.dev/play/p/xNB5bTb97Wd)]
- **<big>Merge</big>** : merge maps, next key will overwrite previous key.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/maputil.md#Merge)]
[[play](https://go.dev/play/p/H95LENF1uB-)]
- **<big>Minus</big>** : creates a map of whose key in mapA but not in mapB.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/maputil.md#Minus)]
[[play](https://go.dev/play/p/3u5U9K7YZ9m)]
- **<big>Values</big>** : returns a slice of the map's values.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/maputil.md#Values)]
[[play](https://go.dev/play/p/CBKdUc5FTW6)]
- **<big>IsDisjoint</big>** : check two map are disjoint if they have no keys in common.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/maputil.md#IsDisjoint)]
[[play](https://go.dev/play/p/N9qgYg_Ho6f)]
### 12. Mathutil package implements some functions for math calculation. ### 12. Mathutil package implements some functions for math calculation.

View File

@@ -398,14 +398,31 @@ import "github.com/duke-git/lancet/v2/maputil"
#### 函数列表: #### 函数列表:
- [ForEach](https://github.com/duke-git/lancet/blob/main/docs/maputil_zh-CN.md#ForEach) - **<big>ForEach</big>** : 对map中的每对key和value执行iteratee函数。
- [Filter](https://github.com/duke-git/lancet/blob/main/docs/maputil_zh-CN.md#Filter) [[doc](https://github.com/duke-git/lancet/blob/main/docs/maputil_zh-CN.md#ForEach)]
- [Intersect](https://github.com/duke-git/lancet/blob/main/docs/maputil_zh-CN.md#Intersect) [[play](https://go.dev/play/p/OaThj6iNVXK)]
- [Keys](https://github.com/duke-git/lancet/blob/main/docs/maputil_zh-CN.md#Keys) - **<big>Filter</big>** : 迭代map中的每对key和value返回map其中的key和value符合predicate函数。
- [Merge](https://github.com/duke-git/lancet/blob/main/docs/maputil_zh-CN.md#Merge) [[doc](https://github.com/duke-git/lancet/blob/main/docs/maputil_zh-CN.md#Filter)]
- [Minus](https://github.com/duke-git/lancet/blob/main/docs/maputil_zh-CN.md#Minus) [[play](https://go.dev/play/p/fSvF3wxuNG7)]
- [Values](https://github.com/duke-git/lancet/blob/main/docs/maputil_zh-CN.md#Values) - **<big>Intersect</big>** : 多个map的交集操作。
- [IsDisjoint](https://github.com/duke-git/lancet/blob/main/docs/maputil_zh-CN.md#IsDisjoint) [[doc](https://github.com/duke-git/lancet/blob/main/docs/maputil_zh-CN.md#Intersect)]
[[play](https://go.dev/play/p/Zld0oj3sjcC)]
- **<big>Keys</big>** : 返回map中所有key组成的切片。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/maputil_zh-CN.md#Keys)]
[[play](https://go.dev/play/p/xNB5bTb97Wd)]
- **<big>Merge</big>** : 合并多个map, 相同的key会被之后的key覆盖。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/maputil_zh-CN.md#Merge)]
[[play](https://go.dev/play/p/H95LENF1uB-)]
- **<big>Minus</big>** : 返回一个map其中的key存在于mapA不存在于mapB。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/maputil_zh-CN.md#Minus)]
[[play](https://go.dev/play/p/3u5U9K7YZ9m)]
- **<big>Values</big>** : 返回map中所有values组成的切片
[[doc](https://github.com/duke-git/lancet/blob/main/docs/maputil_zh-CN.md#Values)]
[[play](https://go.dev/play/p/CBKdUc5FTW6)]
- **<big>IsDisjoint</big>** : 验证两个map是否具有不同的key。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/maputil_zh-CN.md#IsDisjoint)]
[[play](https://go.dev/play/p/N9qgYg_Ho6f)]
### 12. mathutil 包实现了一些数学计算的函数。 ### 12. mathutil 包实现了一些数学计算的函数。

View File

@@ -103,7 +103,7 @@ func Intersect[K comparable, V any](maps ...map[K]V) map[K]V {
return result return result
} }
// Minus creates an map of whose key in mapA but not in mapB. // Minus creates a map of whose key in mapA but not in mapB.
// Play: https://go.dev/play/p/3u5U9K7YZ9m // Play: https://go.dev/play/p/3u5U9K7YZ9m
func Minus[K comparable, V any](mapA, mapB map[K]V) map[K]V { func Minus[K comparable, V any](mapA, mapB map[K]V) map[K]V {
result := make(map[K]V) result := make(map[K]V)