stash/vendor/github.com/asticode/go-astits/wrapping_counter.go
cj c1a096a1a6
Caption support (#2462)
Co-authored-by: WithoutPants <53250216+WithoutPants@users.noreply.github.com>
2022-05-06 11:59:28 +10:00

22 lines
360 B
Go

package astits
type wrappingCounter struct {
wrapAt int
value int
}
func newWrappingCounter(wrapAt int) wrappingCounter {
return wrappingCounter{
wrapAt: wrapAt,
}
}
// returns current counter state and increments internal value
func (c *wrappingCounter) get() int {
ret := c.value
c.value++
if c.value > c.wrapAt {
c.value = 0
}
return ret
}