Skip to content

Instantly share code, notes, and snippets.

@RinniSwift
Created May 8, 2019 00:10
Show Gist options
  • Select an option

  • Save RinniSwift/297adc4be3eef289941d04dfabd3250b to your computer and use it in GitHub Desktop.

Select an option

Save RinniSwift/297adc4be3eef289941d04dfabd3250b to your computer and use it in GitHub Desktop.
class CircularBuffer<T> {
// ...
// 1.
var front: T? {
if isEmpty() {
return nil
} else {
// 2.
return elements[bufferMaxSize - size]
}
}
// 3.
func isEmpty() -> Bool {
return self.size == 0
}
// 4.
func isFull() -> Bool {
return size == bufferMaxSize
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment