优化代码

This commit is contained in:
GoEdgeLab
2023-10-03 21:38:45 +08:00
parent b2c6c3cc07
commit a7856c1c88
6 changed files with 46 additions and 41 deletions

View File

@@ -2,13 +2,13 @@
package linkedlist
type Item struct {
prev *Item
next *Item
type Item[T any] struct {
prev *Item[T]
next *Item[T]
Value interface{}
Value T
}
func NewItem(value interface{}) *Item {
return &Item{Value: value}
func NewItem[T any](value T) *Item[T] {
return &Item[T]{Value: value}
}