Skip to content

Instantly share code, notes, and snippets.

@voddan
Created June 4, 2016 14:28
Show Gist options
  • Save voddan/0df034b7f241ea8c5dc066726778cad0 to your computer and use it in GitHub Desktop.
Save voddan/0df034b7f241ea8c5dc066726778cad0 to your computer and use it in GitHub Desktop.
abstract class CircularList<E, H: Circular<E>>(val size: Int) : Circular<List<E>> {
protected abstract val state: List<H> // state.size == size
override fun inc() {
state.forEach {
it.inc()
if(! it.isZero()) return
}
}
override fun isZero() = state.all {it.isZero()}
override fun hasNext() = state.any {it.hasNext()}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment