MCPcopy Create free account
hub / github.com/FastLED/FastLED / vector_basic

Class vector_basic

src/fl/stl/basic_vector.h:39–186  ·  view source on GitHub ↗

Type-erased vector base class. Holds all vector logic. vector inherits this and provides the element type info. VectorN inherits vector and provides the inline buffer. This class cannot be constructed directly — only through vector .

Source from the content-addressed store, hash-verified

37/// VectorN<T, N> inherits vector<T> and provides the inline buffer.
38/// This class cannot be constructed directly — only through vector<T>.
39class vector_basic {
40 public:
41 // ======= CAPACITY =======
42 fl::size size() const FL_NOEXCEPT { return mSize; }
43 bool empty() const FL_NOEXCEPT { return mSize == 0; }
44 fl::size capacity() const FL_NOEXCEPT { return mCapacity; }
45 bool full() const FL_NOEXCEPT { return mSize >= mCapacity; }
46 fl::size element_size() const FL_NOEXCEPT { return mElementSize; }
47
48 // ======= RAW DATA ACCESS =======
49 void* data_raw() FL_NOEXCEPT { return mArray; }
50 const void* data_raw() const FL_NOEXCEPT { return mArray; }
51
52 // ======= MEMORY MANAGEMENT =======
53 void reserve_impl(fl::size n) FL_NOEXCEPT;
54 void shrink_to_fit_impl() FL_NOEXCEPT;
55
56 // ======= ELEMENT OPERATIONS =======
57 void push_back_copy_impl(const void* element) FL_NOEXCEPT;
58 void push_back_move_impl(void* element) FL_NOEXCEPT;
59 void pop_back_impl() FL_NOEXCEPT;
60 void clear_impl() FL_NOEXCEPT;
61
62 /// Erase element at index. Shifts subsequent elements left.
63 void erase_impl(fl::size index) FL_NOEXCEPT;
64
65 /// Erase range [first_index, first_index + count).
66 void erase_range_impl(fl::size first_index, fl::size count) FL_NOEXCEPT;
67
68 /// Insert element at index by copy. Shifts subsequent elements right.
69 void insert_copy_impl(fl::size index, const void* element) FL_NOEXCEPT;
70
71 /// Insert element at index by move. Shifts subsequent elements right.
72 void insert_move_impl(fl::size index, void* element) FL_NOEXCEPT;
73
74 /// Resize to n elements. New elements are default-constructed (zeroed for trivial).
75 void resize_impl(fl::size n) FL_NOEXCEPT;
76
77 /// Resize to n elements. New elements are copy-constructed from value.
78 void resize_value_impl(fl::size n, const void* value) FL_NOEXCEPT;
79
80 /// Swap contents with another vector_basic.
81 void swap_impl(vector_basic& other) FL_NOEXCEPT;
82
83 // ======= DESTRUCTOR =======
84 ~vector_basic() FL_NOEXCEPT;
85
86 protected:
87 // ======= CONSTRUCTION (only callable by vector<T>) =======
88
89 /// Heap-only vector (no inline buffer).
90 vector_basic(fl::size elementSize, memory_resource* resource,
91 const vector_element_ops* ops) FL_NOEXCEPT
92 : mElementSize(elementSize)
93 , mResource(resource)
94 , mOps(ops)
95 , mInlineOffset(0)
96 , mInlineCapacity(0) {}

Callers 1

vector.hFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected