add AlbumFilter to backend album iterators

This commit is contained in:
Drew Weymouth
2023-05-11 08:54:18 -07:00
parent 5634dfcfc1
commit 882f951aa1
6 changed files with 68 additions and 21 deletions
+6
View File
@@ -17,6 +17,9 @@ func SliceContains[T comparable](ts []T, t T) bool {
}
func FilterSlice[T any](ss []T, test func(T) bool) []T {
if ss == nil {
return nil
}
result := make([]T, 0)
for _, s := range ss {
if test(s) {
@@ -27,6 +30,9 @@ func FilterSlice[T any](ss []T, test func(T) bool) []T {
}
func MapSlice[T any, U any](ts []T, f func(T) U) []U {
if ts == nil {
return nil
}
result := make([]U, len(ts))
for i, t := range ts {
result[i] = f(t)