00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #ifndef QPTRLIST_H
00037 #define QPTRLIST_H
00038
00039 #ifndef QT_H
00040 #include "qglist.h"
00041 #endif // QT_H
00042
00043
00044 template<class type>
00045 class QPtrList
00046 #ifdef Q_QDOC
00047 : public QPtrCollection
00048 #else
00049 : public QGList
00050 #endif
00051 {
00052 public:
00053 QPtrList() {}
00054 QPtrList( const QPtrList<type> &l ) : QGList(l) {}
00055 ~QPtrList() { clear(); }
00056 QPtrList<type> &operator=(const QPtrList<type> &l)
00057 { return (QPtrList<type>&)QGList::operator=(l); }
00058 bool operator==( const QPtrList<type> &list ) const
00059 { return QGList::operator==( list ); }
00060 bool operator!=( const QPtrList<type> &list ) const
00061 { return !QGList::operator==( list ); }
00062 uint count() const { return QGList::count(); }
00063 bool isEmpty() const { return QGList::count() == 0; }
00064 bool insert( uint i, const type *d){ return QGList::insertAt(i,(QPtrCollection::Item)d); }
00065 void inSort( const type *d ) { QGList::inSort((QPtrCollection::Item)d); }
00066 void prepend( const type *d ) { QGList::insertAt(0,(QPtrCollection::Item)d); }
00067 void append( const type *d ) { QGList::append((QPtrCollection::Item)d); }
00068 bool remove( uint i ) { return QGList::removeAt(i); }
00069 bool remove() { return QGList::remove((QPtrCollection::Item)0); }
00070 bool remove( const type *d ) { return QGList::remove((QPtrCollection::Item)d); }
00071 bool removeRef( const type *d ) { return QGList::removeRef((QPtrCollection::Item)d); }
00072 void removeNode( QLNode *n ) { QGList::removeNode(n); }
00073 bool removeFirst() { return QGList::removeFirst(); }
00074 bool removeLast() { return QGList::removeLast(); }
00075 type *take( uint i ) { return (type *)QGList::takeAt(i); }
00076 type *take() { return (type *)QGList::take(); }
00077 type *takeNode( QLNode *n ) { return (type *)QGList::takeNode(n); }
00078 void clear() { QGList::clear(); }
00079 void sort() { QGList::sort(); }
00080 int find( const type *d ) { return QGList::find((QPtrCollection::Item)d); }
00081 int findNext( const type *d ) { return QGList::find((QPtrCollection::Item)d,FALSE); }
00082 int findRef( const type *d ) { return QGList::findRef((QPtrCollection::Item)d); }
00083 int findNextRef( const type *d ){ return QGList::findRef((QPtrCollection::Item)d,FALSE);}
00084 uint contains( const type *d ) const { return QGList::contains((QPtrCollection::Item)d); }
00085 uint containsRef( const type *d ) const
00086 { return QGList::containsRef((QPtrCollection::Item)d); }
00087 bool replace( uint i, const type *d ) { return QGList::replaceAt( i, (QPtrCollection::Item)d ); }
00088 type *at( uint i ) { return (type *)QGList::at(i); }
00089 int at() const { return QGList::at(); }
00090 type *current() const { return (type *)QGList::get(); }
00091 QLNode *currentNode() const { return QGList::currentNode(); }
00092 type *getFirst() const { return (type *)QGList::cfirst(); }
00093 type *getLast() const { return (type *)QGList::clast(); }
00094 type *first() { return (type *)QGList::first(); }
00095 type *last() { return (type *)QGList::last(); }
00096 type *next() { return (type *)QGList::next(); }
00097 type *prev() { return (type *)QGList::prev(); }
00098 void toVector( QGVector *vec )const{ QGList::toVector(vec); }
00099
00100 #ifdef Q_QDOC
00101 protected:
00102 virtual int compareItems( QPtrCollection::Item, QPtrCollection::Item );
00103 virtual QDataStream& read( QDataStream&, QPtrCollection::Item& );
00104 virtual QDataStream& write( QDataStream&, QPtrCollection::Item ) const;
00105 #endif
00106
00107 private:
00108 void deleteItem( Item d );
00109 };
00110
00111 #if !defined(Q_BROKEN_TEMPLATE_SPECIALIZATION)
00112 template<> inline void QPtrList<void>::deleteItem( QPtrCollection::Item )
00113 {
00114 }
00115 #endif
00116
00117 template<class type> inline void QPtrList<type>::deleteItem( QPtrCollection::Item d )
00118 {
00119 if ( del_item ) delete (type *)d;
00120 }
00121
00122 template<class type>
00123 class QPtrListIterator : public QGListIterator
00124 {
00125 public:
00126 QPtrListIterator(const QPtrList<type> &l) :QGListIterator((QGList &)l) {}
00127 ~QPtrListIterator() {}
00128 uint count() const { return list->count(); }
00129 bool isEmpty() const { return list->count() == 0; }
00130 bool atFirst() const { return QGListIterator::atFirst(); }
00131 bool atLast() const { return QGListIterator::atLast(); }
00132 type *toFirst() { return (type *)QGListIterator::toFirst(); }
00133 type *toLast() { return (type *)QGListIterator::toLast(); }
00134 operator type *() const { return (type *)QGListIterator::get(); }
00135 type *operator*() { return (type *)QGListIterator::get(); }
00136
00137
00138
00139
00140
00141
00142
00143 type *current() const { return (type *)QGListIterator::get(); }
00144 type *operator()() { return (type *)QGListIterator::operator()();}
00145 type *operator++() { return (type *)QGListIterator::operator++(); }
00146 type *operator+=(uint j) { return (type *)QGListIterator::operator+=(j);}
00147 type *operator--() { return (type *)QGListIterator::operator--(); }
00148 type *operator-=(uint j) { return (type *)QGListIterator::operator-=(j);}
00149 QPtrListIterator<type>& operator=(const QPtrListIterator<type>&it)
00150 { QGListIterator::operator=(it); return *this; }
00151 };
00152
00153 #ifndef QT_NO_COMPAT
00154 #define QList QPtrList
00155 #define QListIterator QPtrListIterator
00156 #endif
00157
00158 #ifdef QT_QWINEXPORT
00159 #define Q_DEFINED_QPTRLIST
00160 #include "qwinexport.h"
00161 #endif
00162 #endif // QPTRLIST_H