mirror of
https://github.com/Monibuca/engine.git
synced 2025-10-06 09:06:52 +08:00
4.0初步改造
This commit is contained in:
21
util/slice.go
Normal file
21
util/slice.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package util
|
||||
|
||||
type Slice[T comparable] []T
|
||||
|
||||
func (s Slice[T]) Len() int {
|
||||
return len(s)
|
||||
}
|
||||
|
||||
func (s *Slice[T]) Add(v T) {
|
||||
*s = append(*s, v)
|
||||
}
|
||||
|
||||
func (s *Slice[T]) Delete(v T) bool {
|
||||
for i, val := range *s {
|
||||
if val == v {
|
||||
*s = append((*s)[:i], (*s)[i+1:]...)
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
Reference in New Issue
Block a user