mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-30 14:32:37 +08:00
1
This commit is contained in:
parent
dab552aed4
commit
c1af64854c
@ -25,11 +25,21 @@ func DeleteAt[T any](ts []T, index ...int) []T {
|
|||||||
case 0:
|
case 0:
|
||||||
return ts
|
return ts
|
||||||
case 1:
|
case 1:
|
||||||
|
i := index[0]
|
||||||
|
if len(ts) <= i || len(ts) < -i {
|
||||||
|
return ts
|
||||||
|
}
|
||||||
|
if i < 0 {
|
||||||
|
i = len(ts) + i
|
||||||
|
}
|
||||||
return append(ts[:index[0]], ts[index[0]+1:]...)
|
return append(ts[:index[0]], ts[index[0]+1:]...)
|
||||||
default:
|
default:
|
||||||
tmp := make(map[int]struct{})
|
tmp := make(map[int]struct{})
|
||||||
for _, v := range index {
|
for _, i := range index {
|
||||||
tmp[v] = struct{}{}
|
if i < 0 {
|
||||||
|
i = len(ts) + i
|
||||||
|
}
|
||||||
|
tmp[i] = struct{}{}
|
||||||
}
|
}
|
||||||
v := make([]T, 0, len(ts))
|
v := make([]T, 0, len(ts))
|
||||||
for i := 0; i < len(ts); i++ {
|
for i := 0; i < len(ts); i++ {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user