feat: 过滤列表数据方法
This commit is contained in:
@ -26,3 +26,14 @@ func ExtractField[FieldValue any, Value any](dataList []Value, fieldValue func(i
|
|||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Filter 过滤列表数据
|
||||||
|
func Filter[Value any](dataList []Value, filterValue func(item Value) bool) []Value {
|
||||||
|
res := make([]Value, 0)
|
||||||
|
for _, item := range dataList {
|
||||||
|
if filterValue(item) {
|
||||||
|
res = append(res, item)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user