In computer science, a circular buffer, circular queue, cyclic buffer or ring buffer is a data structure that uses a single, fixed-size buffer as if it were connected end-to-end. This structure lends itself easily to buffering data streams. There were early circular buffer implementations in hardware.
A circular buffer first starts out empty and has a set length. In the diagram below is a 7-element buffer:
Assume that 1 is written in the center of a circular buffer (the exact starting location is not important in a circular buffer):
Then assume that two more elements are added to the circular buffer — 2 & 3 — which get put after 1:
If two elements are removed, the two oldest values inside of the circular buffer would be removed. Circular buffers use FIFO (first in, first out) logic. In the example, 1 & 2 were the first to enter the circular buffer, they are the first to be removed, leaving 3 inside of the buffer.
If the buffer has 7 elements, then it is completely full:
A property of the circular buffer is that when it is full and a subsequent write is performed, then it starts overwriting the oldest data. In the current example, two more elements — A & B — are added and they overwrite the 3 & 4:
Alternatively, the routines that manage the buffer could prevent overwriting the data and return an error or raise an exception. Whether or not data is overwritten is up to the semantics of the buffer routines or the application using the circular buffer.
Finally, if two elements are now removed then what would be returned is not 3 & 4 but 5 & 6 because 5 & 6 are now the oldest elements, yielding the buffer with:
The useful property of a circular buffer is that it does not need to have its elements shuffled around when one is consumed. (If a non-circular buffer were used then it would be necessary to shift all elements when one is consumed.) In other words, the circular buffer is well-suited as a FIFO (first in, first out) buffer while a standard, non-circular buffer is well suited as a LIFO (last in, first out) buffer.
This page is automatically generated and may contain information that is not correct, complete, up-to-date, or relevant to your search query. The same applies to every other page on this website. Please make sure to verify the information with EPFL's official sources.
In computer science, a data buffer (or just buffer) is a region of a memory used to temporarily store data while it is being moved from one place to another. Typically, the data is stored in a buffer as it is retrieved from an input device (such as a microphone) or just before it is sent to an output device (such as speakers). However, a buffer may be used when moving data between processes within a computer. This is comparable to buffers in telecommunication.
Explains two-phase construction for arrays, hash tables, and search trees in parallel.
Covers the basics of fully differential amplifiers, including their definition, output swing, and common-mode feedback circuits.
Covers query processing with relational operations, including query optimization and different join algorithms.
Joint Photographic Experts Group (JPEG) XS is a new International Standard from the JPEG Committee (formally known as ISO/International Electrotechnical Commission (IEC) JTC1/SC29/WG1). It defines an interoperable, visually lossless low-latency lightweight ...
Tris(hydroxymethyl)aminomethane (Tris) has been used as the buffer in bioactivity testing for over two decades and has become a standard choice for the scientific community. While it is believed to be non-interacting, the extent of its interactions with ti ...
Amsterdam2021
, , ,
We report the functionalization of cysteine residues with lipophilic alkynes bearing a silyl group or an alkyl chain using amphiphilic ethynylbenziodoxolone reagents (EBXs). The reactions were carried out in buffer (pH 6 to 9), without organic co-solvent o ...