[Buffer]
added contructor for initializer list
This commit is contained in:
+19
-6
@@ -27,6 +27,7 @@
|
|||||||
#define DSP_BUFFER_H
|
#define DSP_BUFFER_H
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <list>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <stdint.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_index(0)
|
||||||
, m_mask(0)
|
, m_mask(0)
|
||||||
, m_offset(0)
|
, m_offset(0)
|
||||||
, m_increment(1)
|
, m_increment(1)
|
||||||
, m_capacity(v.capacity())
|
, m_capacity(v.size())
|
||||||
, m_buffer(v)
|
, m_buffer(*new std::vector<T>(v))
|
||||||
, m_allocated_capacity(1)
|
, m_allocated_capacity(1)
|
||||||
{
|
{
|
||||||
resize(v.capacity());
|
resize(v.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t capacity()
|
size_t capacity() const
|
||||||
{
|
{
|
||||||
return m_capacity/m_increment;
|
return m_capacity/m_increment;
|
||||||
}
|
}
|
||||||
@@ -147,7 +148,19 @@ class Buffer
|
|||||||
|
|
||||||
bool operator == (const Buffer &other) const
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user