4#ifndef QQMLJSFIXEDPOOLARRAY_P_H
5#define QQMLJSFIXEDPOOLARRAY_P_H
18#include <QtCore/qglobal.h>
19#include <private/qqmljsmemorypool_p.h>
37 { allocate(pool, size); }
42 data =
reinterpret_cast<T*>(pool->allocate(count *
sizeof(T)));
45 void allocate(MemoryPool *pool,
const QVector<T> &vector)
47 count = vector.size();
48 data =
reinterpret_cast<T*>(pool->allocate(count *
sizeof(T)));
50 if (QTypeInfo<T>::isComplex) {
51 for (
int i = 0; i < count; ++i)
52 new (data + i) T(vector.at(i));
54 memcpy(data,
static_cast<
const void*>(vector.constData()), count *
sizeof(T));
58 template <
typename Container>
59 void allocate(MemoryPool *pool,
const Container &container)
61 count = container.size();
62 data =
reinterpret_cast<T*>(pool->allocate(count *
sizeof(T)));
63 typename Container::ConstIterator it = container.constBegin();
64 for (
int i = 0; i < count; ++i)
65 new (data + i) T(*it++);
71 const T &
at(
int index)
const {
72 Q_ASSERT(index >= 0 && index < count);
77 Q_ASSERT(index >= 0 && index < count);
87 for (
int i = 0; i < count; ++i)
93 const T *
begin()
const {
return data; }
94 const T *
end()
const {
return data + count; }
97 T *
end() {
return data + count; }
const T & at(int index) const
void allocate(MemoryPool *pool, const QVector< T > &vector)
void allocate(MemoryPool *pool, int size)
T & operator[](int index)
void allocate(MemoryPool *pool, const Container &container)
int indexOf(const T &value) const
FixedPoolArray(MemoryPool *pool, int size)