5// Created by Ilya on 29/11/2018.
10struct CyclicBuffer<T> {
11 private var buffer: [T?]
16 buffer = Array(repeating: nil, count: count)
20 private let queue = DispatchQueue(label: "soy.iko.cyclicBufferqueue", attributes: DispatchQueue.Attributes.concurrent)
22 mutating func append(_ element: T) {
23 queue.sync(flags: .barrier) {
24 self.buffer[self.index] = element
25 self.index = (self.index + 1) % self.size
29 func getLast(count: Int = 1) -> [T] {
33 out = Array((buffer[index..<size] + buffer[0..<index]).lazy
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list