FastLED 3.10.6
Loading...
Searching...
No Matches
deque_basic.h
Go to the documentation of this file.
1#pragma once
2
3// deque_basic: non-template chunk-map arithmetic helper shared by every
4// `fl::deque<T>` instantiation.
5//
6// FastLED's `deque<T>` is a chunked container -- a map of fixed-size chunk
7// pointers with the underlying elements stored in separately-allocated
8// chunks. Element pointers stay valid across push at either end because
9// only the chunk-pointer map ever reallocates, never the chunks. See
10// FastLED #3270 for the design.
11//
12// The map-grow policy is pure arithmetic (current capacity -> next
13// capacity) and doesn't depend on T, so it's emitted once per build via
14// `FL_NO_INLINE` regardless of how many `deque<T>` instantiations exist.
15// Mirrors the dedup pattern from `unordered_map_basic` (#3235 Tier 1C) and
16// `flat_map_basic` (#3239).
17
18#include "fl/stl/cstddef.h"
19#include "fl/stl/compiler_control.h" // for FL_NO_INLINE
20#include "fl/stl/noexcept.h"
21
22namespace fl {
23namespace detail {
24
25// Initial chunk-pointer-map capacity used when the deque first allocates a
26// map. Small enough to amortize cheaply on first push; the map grows by
27// doubling thereafter.
28enum {
30};
31
32// Compute the next chunk-map capacity when the deque's chunk map needs to
33// grow. Doubles from the current capacity (or starts at
34// `kDequeInitialMapCapacity` if `current == 0`) until the result is at
35// least `min_required_chunks`. Saturates to `min_required_chunks` if
36// further doubling would overflow `fl::size` (preventing a non-terminating
37// loop).
38//
39// Caller is responsible for actually allocating the new map and copying
40// chunk pointers across; this helper only computes the target capacity so
41// the doubling loop isn't duplicated per `deque<T>` instantiation.
43fl::size deque_grow_map_capacity(fl::size current_map_capacity,
44 fl::size min_required_chunks) FL_NO_EXCEPT;
45
46} // namespace detail
47} // namespace fl
#define FL_NO_INLINE
@ kDequeInitialMapCapacity
Definition deque_basic.h:29
FL_NO_INLINE fl::size deque_grow_map_capacity(fl::size current_map_capacity, fl::size min_required_chunks) FL_NO_EXCEPT
Compile-time linker keep-alive hook for a single fl::Bus.
Definition bus_info.h:57
InputGamut g FL_NO_EXCEPT
Definition rgbw.h:121
Base definition for an LED controller.
Definition crgb.hpp:179