1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-02-06 13:42:28 +08:00

doc: format code in markdown file

This commit is contained in:
dudaodong
2022-07-20 19:33:02 +08:00
parent aab28b914c
commit bfa46d46a2
2 changed files with 53 additions and 8 deletions

View File

@@ -27,6 +27,7 @@ import (
- [Merge](#Merge)
- [Minus](#Minus)
- [Values](#Values)
- [Values](#Values)
<div STYLE="page-break-after: always;"></div>
@@ -303,13 +304,13 @@ func main() {
}
```
### <span id="Values">Values</span>
<p>Returns a boolean</p>
### <span id="IsDisjoint">IsDisjoint</span>
<p>Checks two are disjoint if they have no keys in common</p>
<b>Signature:</b>
```go
IsDisjoint[K comparable, V any](mapA, mapB map[K]V) bool
func IsDisjoint[K comparable, V any](mapA, mapB map[K]V) bool
```
<b>Example:</b>
@@ -337,18 +338,15 @@ func main() {
4: "c",
5: "d",
}
m3 := map[int]string{
6: "a",
}
ok := maputil.IsDisjoint(m2, m1)
fmt.Println(ok) // false
ok = maputil.IsDisjoint(m2, m3)
fmt.Println(ok) // true
}
```

View File

@@ -231,7 +231,6 @@ func main() {
### <span id="Minus">Minus</span>
<p>返回一个map其中的key存在于mapA不存在于mapB.</p>
@@ -301,4 +300,52 @@ func main() {
fmt.Println(values) // []string{"a", "a", "b", "c", "d"}
}
```
### <span id="IsDisjoint">IsDisjoint</span>
<p>验证两个map是否具有不同的key</p>
<b>函数签名:</b>
```go
func IsDisjoint[K comparable, V any](mapA, mapB map[K]V) bool
```
<b>例子:</b>
```go
package main
import (
"fmt"
"github.com/duke-git/lancet/v2/maputil"
)
func main() {
m1 := map[int]string{
1: "a",
2: "a",
3: "b",
4: "c",
5: "d",
}
m2 := map[int]string{
1: "a",
2: "a",
3: "b",
4: "c",
5: "d",
}
m3 := map[int]string{
6: "a",
}
ok := maputil.IsDisjoint(m2, m1)
fmt.Println(ok) // false
ok = maputil.IsDisjoint(m2, m3)
fmt.Println(ok) // true
}
```