diff options
Diffstat (limited to 'qtinterface/tqt4/Qt/qlist.h')
-rw-r--r-- | qtinterface/tqt4/Qt/qlist.h | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/qtinterface/tqt4/Qt/qlist.h b/qtinterface/tqt4/Qt/qlist.h index 39c3b83..fb4d3e3 100644 --- a/qtinterface/tqt4/Qt/qlist.h +++ b/qtinterface/tqt4/Qt/qlist.h @@ -110,8 +110,8 @@ class QList union { QListData p; QListData::Data *d; }; public: - inline QList() : d(&QListData::shared_null) { d->ref.ref(); } - inline QList(const QList<T> &l) : d(l.d) { d->ref.ref(); if (!d->sharable) detach_helper(); } + inline QList() : d(&QListData::shared_null) { d->ref.ref(); current_index=0; } + inline QList(const QList<T> &l) : d(l.d) { d->ref.ref(); if (!d->sharable) detach_helper(); current_index=0; } ~QList(); QList<T> &operator=(const QList<T> &l); bool operator==(const QList<T> &l) const; @@ -120,6 +120,7 @@ public: operator bool() const; inline operator const QList<T> *() const { return const_cast<QList<T> *>(this); } + inline operator QList<T> *() const { return const_cast<QList<T> *>(this); } inline int size() const { return p.size(); } @@ -159,8 +160,12 @@ public: int indexOf(const T &t, int from = 0) const; int lastIndexOf(const T &t, int from = -1) const; QBool contains(const T &t) const; + inline uint containsRef( const T &t ) { return count(t); }; int count(const T &t) const; + inline T next() { current_index++; return *this[current_index]; } + inline T prev() { current_index--; return *this[current_index]; } + class const_iterator; class iterator { @@ -264,10 +269,10 @@ public: typedef const_iterator ConstIterator; inline int count() const { return p.size(); } inline int length() const { return p.size(); } // Same as count() - inline T& first() { Q_ASSERT(!isEmpty()); return *begin(); } - inline const T& first() const { Q_ASSERT(!isEmpty()); return *begin(); } + inline T& first() { Q_ASSERT(!isEmpty()); current_index=0; return *begin(); } + inline const T& first() const { Q_ASSERT(!isEmpty()); current_index=0; return *begin(); } T& last() { Q_ASSERT(!isEmpty()); return *(--end()); } - const T& last() const { Q_ASSERT(!isEmpty()); return *(--end()); } + const T& last() const { Q_ASSERT(!isEmpty()); current_index=count()-1; return *(--end()); } inline void removeFirst() { Q_ASSERT(!isEmpty()); erase(begin()); } inline void removeLast() { Q_ASSERT(!isEmpty()); erase(--end()); } inline bool startsWith(const T &t) const { return !isEmpty() && first() == t; } @@ -341,6 +346,8 @@ private: void node_destruct(Node *n); void node_copy(Node *from, Node *to, Node *src); void node_destruct(Node *from, Node *to); + + int current_index; }; #if defined(Q_CC_BOR) |