5#ifndef QQMLJSFIXEDPOOLARRAY_P_H
6#define QQMLJSFIXEDPOOLARRAY_P_H
19#include <QtCore/qglobal.h>
20#include <private/qqmljsmemorypool_p.h>
38 { allocate(pool, size); }
43 data =
reinterpret_cast<T*>(pool->allocate(count *
sizeof(T)));
46 void allocate(MemoryPool *pool,
const QList<T> &vector)
48 count = vector.size();
49 data =
reinterpret_cast<T*>(pool->allocate(count *
sizeof(T)));
51 if (QTypeInfo<T>::isComplex) {
52 for (
int i = 0; i < count; ++i)
53 new (data + i) T(vector.at(i));
55 memcpy(data,
static_cast<
const void*>(vector.constData()), count *
sizeof(T));
59 template <
typename Container>
60 void allocate(MemoryPool *pool,
const Container &container)
62 count = container.size();
63 data =
reinterpret_cast<T*>(pool->allocate(count *
sizeof(T)));
64 typename Container::ConstIterator it = container.constBegin();
65 for (
int i = 0; i < count; ++i)
66 new (data + i) T(*it++);
72 const T &
at(
int index)
const {
73 Q_ASSERT(index >= 0 && index < count);
78 Q_ASSERT(index >= 0 && index < count);
88 for (
int i = 0; i < count; ++i)
94 const T *
begin()
const {
return data; }
95 const T *
end()
const {
return data + count; }
98 T *
end() {
return data + count; }
const T & at(int index) const
void allocate(MemoryPool *pool, const QList< 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)