mirror of
https://github.com/abseil/abseil-cpp.git
synced 2026-06-04 12:07:05 +08:00
This change introduces absl::chunked_queue, a sequence container
optimized for use as a FIFO (First-In, First-Out) queue. It is similar
in purpose to std::deque but with different performance trade-offs and
features.
absl::chunked_queue stores elements in a series of
exponentially-growing chunks of memory.
absl::chunked_queue is often a better choice than std::deque in the
following situations:
* Large queues: For very large numbers of elements, the exponential
growth strategy of absl::chunked_queue can lead to fewer, larger
memory allocations compared to std::deque, which can be a
performance advantage.
* Strict FIFO processing: When you only need to add elements to the
back (push_back) and remove them from the front (pop_front).
std::deque should be preferred in the following cases:
* Operations at both ends: std::deque is designed for efficient
insertions and deletions at both the front and the
back. absl::chunked_queue is optimized for push_back and pop_front
and does not offer a pop_back method.
* Random access: std::deque provides amortized O(1) random access to
elements via operator[]. absl::chunked_queue does not support
random access.
PiperOrigin-RevId: 850999629
Change-Id: Ie71737c10b6125b9e498109267cac87a4ca2f9e8
14 KiB
14 KiB