There is a little mistake in implementation a queue using ring buffer, namely in ring buffer class:
var first: T? {
array[readIndex]
}
it should be:
var first: T? {
return isEmpty ? nil : array[readIndex % array.count]
}
There is a little mistake in implementation a queue using ring buffer, namely in ring buffer class:
var first: T? {
array[readIndex]
}
it should be:
var first: T? {
return isEmpty ? nil : array[readIndex % array.count]
}