MayaFlux 0.2.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ resize()

template<typename T >
void MayaFlux::Memory::HistoryBuffer< T >::resize ( size_t  new_capacity)
inline

Resize buffer capacity.

Parameters
new_capacityNew maximum number of samples

Preserves existing data in temporal order. If growing, new slots filled with zeros. If shrinking, oldest data discarded. Count always equals capacity after resize.

Definition at line 527 of file RingBuffer.hpp.

528 {
529 if (new_capacity == m_capacity)
530 return;
531
532 std::vector<T> current_data;
533 current_data.reserve(m_count);
534 for (size_t i = 0; i < m_count; ++i) {
535 current_data.push_back(m_data[(m_head + i) % m_capacity]);
536 }
537
538 m_capacity = new_capacity;
539 m_data.resize(new_capacity, T {});
540 m_linear_view.resize(new_capacity);
541
542 size_t to_copy = std::min(current_data.size(), new_capacity);
543 for (size_t i = 0; i < to_copy; ++i) {
544 m_data[i] = current_data[i];
545 }
546
547 m_head = 0;
549 }

References MayaFlux::Memory::HistoryBuffer< T >::m_capacity, MayaFlux::Memory::HistoryBuffer< T >::m_count, MayaFlux::Memory::HistoryBuffer< T >::m_data, MayaFlux::Memory::HistoryBuffer< T >::m_head, and MayaFlux::Memory::HistoryBuffer< T >::m_linear_view.

Referenced by MayaFlux::Nodes::Generator::Polynomial::set_buffer_function().

+ Here is the caller graph for this function: