Alle boeken

Professioneel

Apps Over Coach Inloggen Begin met lezen

Computer Science · Begrippenlijst

Wat is Circular buffer?

Definition 14.8 University Computer Science — Year 1 · Hoofdstuk 14 — Dynamic Arrays and Amortised Analysis

A circular buffer stores a queue in an array of capacity cc with a head index hh and a count kk: the queue is a[h],a[(h+1) mod c],…,a[(h+k−1) mod c]a[h], a[(h + 1) \bmod c], \dots, a[(h + k - 1) \bmod c]. Taking the front advances hh modulo cc; adding at the back writes a[(h+k) mod c]a[(h + k) \bmod c].

A circular buffer before and after it grows. On the left, the queue 3, 4, 5, 6 has wrapped: it starts at index 2 and continues at index 0. Growing copies the queue in order to the start of a larger array.
A circular buffer before and after it grows. On the left, the queue 3, 4, 5, 6 has wrapped: it starts at index 2 and continues at index 0. Growing copies the queue in order to the start of a larger array.
Lees in het hoofdstuk →