Skip to content

Instantly share code, notes, and snippets.

@voddan
Created June 4, 2016 14:26
Show Gist options
  • Save voddan/c22728d0e3b5ed8210df1a0b97c1df87 to your computer and use it in GitHub Desktop.
Save voddan/c22728d0e3b5ed8210df1a0b97c1df87 to your computer and use it in GitHub Desktop.
class Ring(val size: Int) : Circular<Int> {
private var state = 0
override fun state() = state
override fun inc() {state = (1 + state) % size}
override fun isZero() = (state == 0)
override fun hasNext() = (state != size - 1)
init {
assert(size > 0)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment