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

Method resize

src/fl/stl/circular_buffer.h:262–279  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

260 void clear() { mCore.clear(); }
261
262 void resize(fl::size new_capacity) {
263 // Save existing elements
264 fl::size count = mCore.size();
265 fl::size to_save = (count < new_capacity) ? count : new_capacity;
266 // Use a temporary storage to save elements
267 vector_inlined<T, (N > 0 ? N : 1)> saved;
268 saved.resize(to_save);
269 for (fl::size i = 0; i < to_save; ++i) {
270 saved[i] = mCore[i];
271 }
272 // Resize storage
273 mStorage.resize(new_capacity);
274 mCore.assign(mStorage.data(), new_capacity);
275 // Re-insert saved elements
276 for (fl::size i = 0; i < to_save; ++i) {
277 mCore.push_back(saved[i]);
278 }
279 }
280
281 /// Equality comparison
282 bool operator==(const circular_buffer& other) const {

Callers 1

circular_bufferMethod · 0.45

Calls 4

sizeMethod · 0.45
assignMethod · 0.45
dataMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected