snapshots: Handle as separate components
This commit is contained in:
parent
698f04e13e
commit
3b112f1b8e
27 changed files with 960 additions and 789 deletions
|
|
@ -26,6 +26,16 @@ func Filter[T any](values []T, filter func(T) bool) []T {
|
|||
return results
|
||||
}
|
||||
|
||||
// FilterClone is like [Filter], but creates a new slice
|
||||
func FilterClone[T any](values []T, filter func(T) bool) (results []T) {
|
||||
for _, value := range values {
|
||||
if filter(value) {
|
||||
results = append(results, value)
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// NonSequential sorts values, and then removes elements for which test() returns true.
|
||||
// NonSequential does not re-allocate, but uses the existing slice.
|
||||
func NonSequential[T constraints.Ordered](values []T, test func(prev, current T) bool) []T {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue