Definition at line 60 of file qvarlengtharray.h.
#include <qvarlengtharray.h>
Public Types |
|
| typedef int | size_type |
| typedef T | value_type |
| typedef value_type * | pointer |
| typedef const value_type * | const_pointer |
| typedef value_type & | reference |
| typedef const value_type & | const_reference |
| typedef qptrdiff | difference_type |
Public Member Functions |
|
| QVarLengthArray (int size=0) | |
| QVarLengthArray (const QVarLengthArray< T, Prealloc > &other) | |
| ~QVarLengthArray () | |
| QVarLengthArray< T, Prealloc > & | operator= (const QVarLengthArray< T, Prealloc > &other) |
| void | removeLast () |
| int | size () const |
| int | count () const |
| bool | isEmpty () const |
| void | resize (int size) |
| void | clear () |
| int | capacity () const |
| void | reserve (int size) |
| T & | operator[] (int idx) |
| const T & | operator[] (int idx) const |
| const T & | at (int idx) const |
| T | value (int i) const |
| T | value (int i, const T &defaultValue) const |
| void | append (const T &t) |
| void | append (const T *buf, int size) |
| T * | data () |
| const T * | data () const |
| const T * | constData () const |
Friends |
|
| class | QPodList< T, Prealloc > |
| typedef int size_type |
Definition at line 130 of file qvarlengtharray.h.
| typedef T value_type |
Definition at line 131 of file qvarlengtharray.h.
| typedef value_type* pointer |
Definition at line 132 of file qvarlengtharray.h.
| typedef const value_type* const_pointer |
Definition at line 133 of file qvarlengtharray.h.
| typedef value_type& reference |
Definition at line 134 of file qvarlengtharray.h.
| typedef const value_type& const_reference |
Definition at line 135 of file qvarlengtharray.h.
| typedef qptrdiff difference_type |
Definition at line 136 of file qvarlengtharray.h.
| Q_INLINE_TEMPLATE QVarLengthArray | ( | int | size = 0 |
) | [inline, explicit] |
Definition at line 154 of file qvarlengtharray.h.
: s(asize) {
if (s > Prealloc) {
ptr = reinterpret_cast<T *>(qMalloc(s * sizeof(T)));
Q_CHECK_PTR(ptr);
a = s;
} else {
ptr = reinterpret_cast<T *>(array);
a = Prealloc;
}
if (QTypeInfo<T>::isComplex) {
T *i = ptr + s;
while (i != ptr)
new (--i) T;
}
}
| QVarLengthArray | ( | const QVarLengthArray< T, Prealloc > & | other | ) | [inline] |
| ~QVarLengthArray | ( | ) | [inline] |
Definition at line 71 of file qvarlengtharray.h.
{
if (QTypeInfo<T>::isComplex) {
T *i = ptr + s;
while (i-- != ptr)
i->~T();
}
if (ptr != reinterpret_cast<T *>(array))
qFree(ptr);
}
| QVarLengthArray<T, Prealloc>& operator= | ( | const QVarLengthArray< T, Prealloc > & | other | ) | [inline] |
| void removeLast | ( | ) | [inline] |
Definition at line 89 of file qvarlengtharray.h.
{
Q_ASSERT(s > 0);
realloc(s - 1, a);
}
| int size | ( | ) | const [inline] |
| int count | ( | ) | const [inline] |
| bool isEmpty | ( | ) | const [inline] |
| Q_INLINE_TEMPLATE void resize | ( | int | size | ) | [inline] |
Definition at line 172 of file qvarlengtharray.h.
{ realloc(asize, qMax(asize, a)); }
| void clear | ( | ) | [inline] |
| int capacity | ( | ) | const [inline] |
| Q_INLINE_TEMPLATE void reserve | ( | int | size | ) | [inline] |
Definition at line 176 of file qvarlengtharray.h.
{ if (asize > a) realloc(s, asize); }
| T& operator[] | ( | int | idx | ) | [inline] |
Definition at line 102 of file qvarlengtharray.h.
{
Q_ASSERT(idx >= 0 && idx < s);
return ptr[idx];
}
| const T& operator[] | ( | int | idx | ) | const [inline] |
Definition at line 106 of file qvarlengtharray.h.
{
Q_ASSERT(idx >= 0 && idx < s);
return ptr[idx];
}
| const T& at | ( | int | idx | ) | const [inline] |
Definition at line 110 of file qvarlengtharray.h.
{ return operator[](idx); }
| Q_OUTOFLINE_TEMPLATE T value | ( | int | i | ) | const |
Definition at line 262 of file qvarlengtharray.h.
| Q_OUTOFLINE_TEMPLATE T value | ( | int | i, |
| const T & | defaultValue | ||
| ) | const |
Definition at line 270 of file qvarlengtharray.h.
| void append | ( | const T & | t | ) | [inline] |
Definition at line 115 of file qvarlengtharray.h.
{
if (s == a) // i.e. s != 0
realloc(s, s<<1);
const int idx = s++;
if (QTypeInfo<T>::isComplex) {
new (ptr + idx) T(t);
} else {
ptr[idx] = t;
}
}
| Q_OUTOFLINE_TEMPLATE void append | ( | const T * | buf, |
| int | size | ||
| ) |
Definition at line 180 of file qvarlengtharray.h.
{
Q_ASSERT(abuf);
if (increment <= 0)
return;
const int asize = s + increment;
if (asize >= a)
realloc(s, qMax(s*2, asize));
if (QTypeInfo<T>::isComplex) {
// call constructor for new objects (which can throw)
while (s < asize)
new (ptr+(s++)) T(*abuf++);
} else {
qMemCopy(&ptr[s], abuf, increment * sizeof(T));
s = asize;
}
}
| T* data | ( | ) | [inline] |
| const T* data | ( | ) | const [inline] |
| const T* constData | ( | ) | const [inline] |
friend class QPodList< T, Prealloc >
[friend] |
Definition at line 139 of file qvarlengtharray.h.
Definition at line 147 of file qvarlengtharray.h.
Definition at line 148 of file qvarlengtharray.h.
| double q_for_alignment_2 |
Definition at line 149 of file qvarlengtharray.h.