ds/utils.go

16 lines
209 B
Go
Raw Normal View History

2023-07-10 17:16:51 +02:00
package ds
func modAbs(a, b int) int {
v := a % b
if v < 0 {
return b + v
}
return v
}
func preAllocList[T any, L List[T]](list L, value T, size int) {
for list.Size() < size {
list.Add(value)
}
}