diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2010-04-07 00:06:28 (GMT) |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2010-04-07 00:06:28 (GMT) |
commit | ca4bc7c16bdf27855a13b15dbabd8019ab2bef24 (patch) | |
tree | c15bc918bd87994d83b87ef922da9cc17253d92d /src/corelib/tools/qvarlengtharray.h | |
parent | 739c1c6a4322c0d48afd2a24e3dc2156fee577e1 (diff) | |
parent | 71a328397720af7229fd6ee48acaa19f7339a8de (diff) | |
download | Qt-ca4bc7c16bdf27855a13b15dbabd8019ab2bef24.zip Qt-ca4bc7c16bdf27855a13b15dbabd8019ab2bef24.tar.gz Qt-ca4bc7c16bdf27855a13b15dbabd8019ab2bef24.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7
Diffstat (limited to 'src/corelib/tools/qvarlengtharray.h')
-rw-r--r-- | src/corelib/tools/qvarlengtharray.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/corelib/tools/qvarlengtharray.h b/src/corelib/tools/qvarlengtharray.h index aecb66e..9773d4b 100644 --- a/src/corelib/tools/qvarlengtharray.h +++ b/src/corelib/tools/qvarlengtharray.h @@ -107,6 +107,10 @@ public: Q_ASSERT(idx >= 0 && idx < s); return ptr[idx]; } + inline const T &at(int idx) const { return operator[](idx); } + + T value(int i) const; + T value(int i, const T &defaultValue) const; inline void append(const T &t) { if (s == a) // i.e. s != 0 @@ -248,6 +252,21 @@ Q_OUTOFLINE_TEMPLATE void QVarLengthArray<T, Prealloc>::realloc(int asize, int a } } +template <class T, int Prealloc> +Q_OUTOFLINE_TEMPLATE T QVarLengthArray<T, Prealloc>::value(int i) const +{ + if (i < 0 || i >= size()) { + return T(); + } + return at(i); +} +template <class T, int Prealloc> +Q_OUTOFLINE_TEMPLATE T QVarLengthArray<T, Prealloc>::value(int i, const T &defaultValue) const +{ + return (i < 0 || i >= size()) ? defaultValue : at(i); +} + + QT_END_NAMESPACE QT_END_HEADER |