Remove template <class T> class QRingBuffer

.. as it is declared and defined in .cpp file but never used.

Change-Id: I7b72daf62712b4ec25717afbe2b7f0792ffa2a85
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
This commit is contained in:
João Abecasis 2011-12-12 13:37:51 +01:00 committed by Qt by Nokia
parent c9d6def002
commit e7a6906da6

View File

@ -720,78 +720,6 @@ inline void QInt64Set::clear()
m_count = 0;
}
//============================================================================//
// QRingBuffer //
//============================================================================//
// T must be POD.
template <class T>
class QRingBuffer
{
public:
inline QRingBuffer() : m_array(0), m_head(0), m_size(0), m_capacity(0) { }
inline ~QRingBuffer() {if (m_array) delete[] m_array;}
bool reallocate(int capacity);
inline const T &head() const {Q_ASSERT(m_size > 0); return m_array[m_head];}
inline const T &dequeue();
inline void enqueue(const T &x);
inline bool isEmpty() const {return m_size == 0;}
private:
T *m_array;
int m_head;
int m_size;
int m_capacity;
};
template <class T>
bool QRingBuffer<T>::reallocate(int capacity)
{
T *oldArray = m_array;
m_array = new T[capacity];
if (m_array) {
if (oldArray) {
if (m_head + m_size > m_capacity) {
memcpy(m_array, oldArray + m_head, (m_capacity - m_head) * sizeof(T));
memcpy(m_array + (m_capacity - m_head), oldArray, (m_head + m_size - m_capacity) * sizeof(T));
} else {
memcpy(m_array, oldArray + m_head, m_size * sizeof(T));
}
delete[] oldArray;
}
m_capacity = capacity;
m_head = 0;
return true;
} else {
m_array = oldArray;
return false;
}
}
template <class T>
inline const T &QRingBuffer<T>::dequeue()
{
Q_ASSERT(m_size > 0);
Q_ASSERT(m_array);
Q_ASSERT(m_capacity >= m_size);
int index = m_head;
if (++m_head >= m_capacity)
m_head -= m_capacity;
--m_size;
return m_array[index];
}
template <class T>
inline void QRingBuffer<T>::enqueue(const T &x)
{
if (m_size == m_capacity)
reallocate(qMax(2 * m_capacity, 64));
int index = m_head + m_size;
if (index >= m_capacity)
index -= m_capacity;
m_array[index] = x;
++m_size;
}
//============================================================================//
// QTriangulator //
//============================================================================//