added contructor for initializer list
This commit is contained in:
2025-11-05 08:22:17 +01:00
parent 8637371035
commit c627cd2dd7
+19 -6
View File
@@ -27,6 +27,7 @@
#define DSP_BUFFER_H
#include <vector>
#include <list>
#include <cstddef>
#include <math.h>
#include <stdint.h>
@@ -72,19 +73,19 @@ class Buffer
{
}
Buffer(const std::vector<T> &v)
Buffer(std::initializer_list<T> v)
: m_index(0)
, m_mask(0)
, m_offset(0)
, m_increment(1)
, m_capacity(v.capacity())
, m_buffer(v)
, m_capacity(v.size())
, m_buffer(*new std::vector<T>(v))
, m_allocated_capacity(1)
{
resize(v.capacity());
resize(v.size());
}
size_t capacity()
size_t capacity() const
{
return m_capacity/m_increment;
}
@@ -147,7 +148,19 @@ class Buffer
bool operator == (const Buffer &other) const
{
return m_buffer == other.m_buffer;
if (this->capacity() != other.capacity())
{
return false;
}
for (int i=0; i < this->capacity(); i++)
{
if (this->m_buffer[i] != other.m_buffer[i])
{
return false;
}
}
return true;
}