MayaFlux 0.5.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 609 of file RingBuffer.hpp.

610 {
611 if (new_capacity == m_capacity)
612 return;
613
614 std::vector<T> current_data;
615 current_data.reserve(m_count);
616 for (size_t i = 0; i < m_count; ++i) {
617 current_data.push_back(m_data[(m_head + i) % m_capacity]);
618 }
619
620 m_capacity = new_capacity;
621 m_data.resize(new_capacity, T {});
622 m_linear_view.resize(new_capacity);
623
624 size_t to_copy = std::min(current_data.size(), new_capacity);
625 for (size_t i = 0; i < to_copy; ++i) {
626 m_data[i] = current_data[i];
627 }
628
629 m_head = 0;
631 }

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: