Created
May 8, 2019 00:10
-
-
Save RinniSwift/297adc4be3eef289941d04dfabd3250b to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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