From 809b7a53df38881a5b2d91d0cd540f28889b6762 Mon Sep 17 00:00:00 2001 From: dudaodong Date: Sat, 3 Dec 2022 14:33:15 +0800 Subject: [PATCH] doc: update docment for slice package --- docs/slice.md | 33 +++++++++++++++++---------------- docs/slice_zh-CN.md | 20 ++++++++++---------- 2 files changed, 27 insertions(+), 26 deletions(-) diff --git a/docs/slice.md b/docs/slice.md index d7c93f2..9ab0c9d 100644 --- a/docs/slice.md +++ b/docs/slice.md @@ -82,12 +82,12 @@ import ( ### AppendIfAbsent -

If slice doesn't contain the value, append it to the slice.

+

If slice doesn't contain the item, append it to the slice.

Signature: ```go -func AppendIfAbsent[T comparable](slice []T, value T) []T +func AppendIfAbsent[T comparable](slice []T, item T) []T ``` Example: @@ -110,12 +110,12 @@ func main() { ### Contain -

Check if the value is in the slice or not.

+

Check if the target value is in the slice or not.

Signature: ```go -func Contain[T comparable](slice []T, value T) bool +func Contain[T comparable](slice []T, target T) bool ``` Example: @@ -139,7 +139,7 @@ func main() { Signature: ```go -func ContainSubSlice[T comparable](slice, subslice []T) bool +func ContainSubSlice[T comparable](slice, subSlice []T) bool ``` Example: @@ -207,12 +207,12 @@ func main() { ### Concat -

Creates a new slice concatenating slice with any additional slices and/or values.

+

Creates a new slice concatenating slice with any additional slices.

Signature: ```go -func Concat[T any](slice []T, values ...[]T) []T +func Concat[T any](slice []T, slices ...[]T) []T ``` Example: @@ -746,6 +746,7 @@ func main() { return math.Floor(num) } res := slice.GroupWith(nums, floor) + fmt.Println(res) //map[float64][]float64{ 4: {4.2}, 6: {6.1, 6.3},} } ``` @@ -858,12 +859,12 @@ func main() { ### IndexOf -

Returns the index at which the first occurrence of a value is found in a slice or return -1 if the value cannot be found.

+

Returns the index at which the first occurrence of a item is found in a slice or return -1 if the item cannot be found.

Signature: ```go -func IndexOf[T comparable](slice []T, value T) int +func IndexOf[T comparable](slice []T, item T) int ``` Example: @@ -886,12 +887,12 @@ func main() { ### LastIndexOf -

Returns the index at which the last occurrence of a value is found in a slice or return -1 if the value cannot be found.

+

Returns the index at which the last occurrence of a item is found in a slice or return -1 if the item cannot be found.

Signature: ```go -func LastIndexOf[T comparable](slice []T, value T) int +func LastIndexOf[T comparable](slice []T, item T) int ``` Example: @@ -1344,12 +1345,12 @@ func main() { ### ToSlice -

Returns a slices of a variable parameter transformation

+

Creates a slice of give items.

Signature: ```go -func ToSlice[T any](value ...T) []T +func ToSlice[T any](items ...T) []T ``` Example: @@ -1373,7 +1374,7 @@ func main() { Signature: ```go -func ToSlicePointer[T any](value ...T) []*T +func ToSlicePointer[T any](items ...T) []*T ``` Example: @@ -1524,12 +1525,12 @@ func main() { ### Without -

Creates a slice excluding all given values.

+

Creates a slice excluding all given items.

Signature: ```go -func Without[T comparable](slice []T, values ...T) []T +func Without[T comparable](slice []T, items ...T) []T ``` Example: diff --git a/docs/slice_zh-CN.md b/docs/slice_zh-CN.md index a68d4d7..fb92a42 100644 --- a/docs/slice_zh-CN.md +++ b/docs/slice_zh-CN.md @@ -90,7 +90,7 @@ import ( 函数签名: ```go -func AppendIfAbsent[T comparable](slice []T, value T) []T +func AppendIfAbsent[T comparable](slice []T, item T) []T ``` 例子: @@ -118,7 +118,7 @@ func main() { 函数签名: ```go -func Contain[T comparable](slice []T, value T) bool +func Contain[T comparable](slice []T, target T) bool ``` 例子: @@ -142,7 +142,7 @@ func main() { 函数签名: ```go -func ContainSubSlice[T comparable](slice, subslice []T) bool +func ContainSubSlice[T comparable](slice, subSlice []T) bool ``` 例子: @@ -210,12 +210,12 @@ func main() { ### Concat -

连接values到slice中,values类型可以是切片或多个值

+

合并多个slices到slice中

函数签名: ```go -func Concat[T any](slice []T, values ...[]T) []T +func Concat[T any](slice []T, slices ...[]T) []T ``` 例子: @@ -865,7 +865,7 @@ func main() { 函数签名: ```go -func IndexOf[T comparable](slice []T, value T) int +func IndexOf[T comparable](slice []T, item T) int ``` 例子: @@ -893,7 +893,7 @@ func main() { 函数签名: ```go -func LastIndexOf[T comparable](slice []T, value T) int +func LastIndexOf[T comparable](slice []T, item T) int ``` 例子: @@ -1347,7 +1347,7 @@ func main() { 函数签名: ```go -func ToSlice[T any](value ...T) []T +func ToSlice[T any](items ...T) []T ``` 例子: @@ -1371,7 +1371,7 @@ func main() { 函数签名: ```go -func ToSlicePointer[T any](value ...T) []*T +func ToSlicePointer[T any](items ...T) []*T ``` 例子: @@ -1527,7 +1527,7 @@ func main() { 函数签名: ```go -func Without[T comparable](slice []T, values ...T) []T +func Without[T comparable](slice []T, items ...T) []T ``` 例子: