Skip to content

Instantly share code, notes, and snippets.

@xd2
Created April 16, 2020 21:29
Show Gist options
  • Save xd2/cce6191e3b21b76d9ef0471409f195c6 to your computer and use it in GitHub Desktop.
Save xd2/cce6191e3b21b76d9ef0471409f195c6 to your computer and use it in GitHub Desktop.
class CircularBuffer(entrySize: Int, private val capacity: Int) {
private var buffers = Array(capacity) { ByteArray(entrySize) }
private var index = 0
fun next(): ByteArray {
val buffer = buffers[index]
index = ++index % capacity
return buffer
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment