Skip to content

Commit e3ddd84

Browse files
committed
refactor: upgrade go dependencies, remove unnecessary dependencies and code
1 parent dcad790 commit e3ddd84

File tree

8 files changed

+35
-539
lines changed

8 files changed

+35
-539
lines changed

backend/utils/coll/queue.go

Lines changed: 0 additions & 82 deletions
This file was deleted.

backend/utils/coll/set.go

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
package coll
22

33
import (
4+
"encoding/json"
45
"fmt"
5-
json "github.com/bytedance/sonic"
66
"sort"
77
. "tinyrdm/backend/utils"
8-
"tinyrdm/backend/utils/rand"
98
)
109

1110
type Void struct{}
@@ -167,31 +166,6 @@ func (s Set[T]) Filter(filterFunc func(i T) bool) []T {
167166
return ret
168167
}
169168

170-
// RandomElem 随机抽取一个元素
171-
// @param remove 随机出来的元素是否同时从集合中移除
172-
// @return 抽取的元素
173-
// @return 是否抽取成功
174-
func (s Set[T]) RandomElem(remove bool) (T, bool) {
175-
size := s.Size()
176-
if size > 0 {
177-
selIdx := rand.Intn(size)
178-
idx := 0
179-
for elem := range s {
180-
if idx == selIdx {
181-
if remove {
182-
delete(s, elem)
183-
}
184-
return elem, true
185-
} else {
186-
idx++
187-
}
188-
}
189-
}
190-
191-
var r T
192-
return r, false
193-
}
194-
195169
// Size 集合长度
196170
func (s Set[T]) Size() int {
197171
return len(s)

backend/utils/coll/stack.go

Lines changed: 0 additions & 88 deletions
This file was deleted.

backend/utils/rand/random.go

Lines changed: 0 additions & 103 deletions
This file was deleted.

0 commit comments

Comments
 (0)