mirror of
https://github.com/coder/coder.git
synced 2026-06-02 20:48:20 +00:00
chore: implement oom/ood processing component (#16436)
Implements the processing logic as set out in the OOM/OOD RFC.
This commit is contained in:
@@ -177,3 +177,19 @@ func DifferenceFunc[T any](a []T, b []T, equal func(a, b T) bool) []T {
|
||||
}
|
||||
return tmp
|
||||
}
|
||||
|
||||
func CountConsecutive[T comparable](needle T, haystack ...T) int {
|
||||
maxLength := 0
|
||||
curLength := 0
|
||||
|
||||
for _, v := range haystack {
|
||||
if v == needle {
|
||||
curLength++
|
||||
} else {
|
||||
maxLength = max(maxLength, curLength)
|
||||
curLength = 0
|
||||
}
|
||||
}
|
||||
|
||||
return max(maxLength, curLength)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user