mirror of
https://github.com/charlienet/go-mixed.git
synced 2025-07-18 08:32:40 +08:00
list
This commit is contained in:
35
collections/list/list.go
Normal file
35
collections/list/list.go
Normal file
@ -0,0 +1,35 @@
|
||||
package list
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/charlienet/go-mixed/locker"
|
||||
)
|
||||
|
||||
var ErrorOutOffRange = errors.New("out of range")
|
||||
|
||||
type List[T any] interface {
|
||||
}
|
||||
|
||||
type list[T any] struct {
|
||||
size int
|
||||
locker locker.RWLocker
|
||||
}
|
||||
|
||||
func (l *list[T]) Synchronize() {
|
||||
l.locker = locker.NewRWLocker()
|
||||
}
|
||||
|
||||
func (l *list[T]) ForEach(fn func(T) bool) { panic("Not Implemented") }
|
||||
|
||||
func (l *LinkedList[T]) ToSlice() []T {
|
||||
s := make([]T, 0, l.Size())
|
||||
l.ForEach(func(t T) bool {
|
||||
s = append(s, t)
|
||||
return false
|
||||
})
|
||||
|
||||
return s
|
||||
}
|
||||
|
||||
func (l *list[T]) Size() int { return l.size }
|
Reference in New Issue
Block a user