fn bufferIndex(deque: *const Self, index: usize) usize deque: *const Selfindex: usize354
355
356
357
358
359
360
361
362
363 fn bufferIndex(deque: *const Self, index: usize) usize {
// This function is written in this way to avoid overflow and
// expensive division.
const head_len = deque.buffer.len - deque.head;
if (index < head_len) {
return deque.head + index;
} else {
return index - head_len;
}
}
Returns the index in
bufferwhere the element at the given index in the logical deque is stored.