A circular buffer is a bounded FIFO structure for double values. Append adds at the rear; pop removes the oldest value from the front. Storage wraps around, allowing positions to reuse a dynamically allocated array without exceeding its maximum length. section 13.1.1
TAKEAWAY: Treat the type through its interface and pair each allocation strategy with its matching cleanup.
- Use circular_init and circular_destroy with an existing circular object. section 13.1.1
- Use circular_new and circular_delete when the buffer itself is allocated dynamically. section 13.1.1
- Inspect positions with circular_element and query the stored count with circular_getlength; resize only when the new capacity can retain the current elements. section 13.1.1
typedef struct circular circular;
!@%STYLE%@!
{"css":"{\"css\": \"font-weight: bold;\"}","target":"[[{\"line\":0,\"ch\":0},{\"line\":0,\"ch\":14}]]"}
!@%STYLE%@!
The opaque typedef exposes a usable circular type while hiding its representation. section 13.1.1
