![]() |
Workspace 7.1.0
|
An array class similar to std::vector or QVector. More...
#include <Workspace/Application/LanguageUtils/variablelengtharray.h>
Classes | |
class | const_iterator |
class | iterator |
Public Member Functions | |
VariableLengthArray ()=default | |
VariableLengthArray (const VariableLengthArray< T, StackPrealloc > &other) | |
VariableLengthArray (int size) | |
void | append (const T &item) |
void | append (const T *buf, int size) |
void | append (const VariableLengthArray< T, StackPrealloc > &other) |
T & | back () |
const T & | back () const |
iterator | begin () |
const_iterator | begin () const |
int | capacity () const |
void | clear () |
const T * | constData () const |
bool | contains (const T &element) const |
int | count () const |
T * | data () |
const T * | data () const |
bool | empty () const |
iterator | end () |
const_iterator | end () const |
T & | first () |
const T & | first () const |
T & | front () |
const T & | front () const |
bool | isEmpty () const |
T & | last () |
const T & | last () const |
VariableLengthArray & | operator= (const VariableLengthArray< T, StackPrealloc > &other) |
bool | operator== (const VariableLengthArray< T, StackPrealloc > &other) const |
T & | operator[] (int idx) |
const T & | operator[] (int idx) const |
void | pop_back () |
void | push_back (const T &item) |
void | reserve (int size) |
void | resize (int size) |
int | size () const |
Static Public Attributes | |
static const int | STACK_PREALLOC = StackPrealloc |
The reasons for this are:
-STL containers (vector, list etc) cannot be safely exported from modules - issues will arise if the clients STL library is not exactly the same. Under Windows it is possible but will give compiler warnings (http://support.microsoft.com/kb/168958). The general consensus is that this should be avoided.
-QVector and QList are terrible in terms of re-allocations under situations when you want to empty the list and reuse it. Unlike std::vector these Qt classes deallocate memory when cleared. This class is based on QVarLengthArray which also has the advantage of using stack memory (rather than heap memory) as long as the size stays smaller than the provided template parameter.
-QVarLengthArray is missing a number of features so this class is a simple wrapper around it that add a few helpful methods.
Do not use Qt foreach() with this class as it does not use implicit sharing and foreach()
|
default |
|
inline |
|
inlineexplicit |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
static |