Created
June 4, 2016 14:26
-
-
Save voddan/c22728d0e3b5ed8210df1a0b97c1df87 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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