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
00037
00038 #ifndef QINTDICT_H
00039 #define QINTDICT_H
00040
00041 #ifndef QT_H
00042 #include "qgdict.h"
00043 #endif // QT_H
00044
00045 template<class type>
00046 class QIntDict
00047 #ifdef Q_QDOC
00048 : public QPtrCollection
00049 #else
00050 : public QGDict
00051 #endif
00052 {
00053 public:
00054 QIntDict(int size=17) : QGDict(size,IntKey,0,0) {}
00055 QIntDict( const QIntDict<type> &d ) : QGDict(d) {}
00056 ~QIntDict() { clear(); }
00057 QIntDict<type> &operator=(const QIntDict<type> &d)
00058 { return (QIntDict<type>&)QGDict::operator=(d); }
00059 uint count() const { return QGDict::count(); }
00060 uint size() const { return QGDict::size(); }
00061 bool isEmpty() const { return QGDict::count() == 0; }
00062 void insert( long k, const type *d )
00063 { QGDict::look_int(k,(Item)d,1); }
00064 void replace( long k, const type *d )
00065 { QGDict::look_int(k,(Item)d,2); }
00066 bool remove( long k ) { return QGDict::remove_int(k); }
00067 type *take( long k ) { return (type*)QGDict::take_int(k); }
00068 type *find( long k ) const
00069 { return (type *)((QGDict*)this)->QGDict::look_int(k,0,0); }
00070 type *operator[]( long k ) const
00071 { return (type *)((QGDict*)this)->QGDict::look_int(k,0,0); }
00072 void clear() { QGDict::clear(); }
00073 void resize( uint n ) { QGDict::resize(n); }
00074 void statistics() const { QGDict::statistics(); }
00075
00076 #ifdef Q_QDOC
00077 protected:
00078 virtual QDataStream& read( QDataStream &, QPtrCollection::Item & );
00079 virtual QDataStream& write( QDataStream &, QPtrCollection::Item ) const;
00080 #endif
00081
00082 private:
00083 void deleteItem( Item d );
00084 };
00085
00086 #if !defined(Q_BROKEN_TEMPLATE_SPECIALIZATION)
00087 template<> inline void QIntDict<void>::deleteItem( QPtrCollection::Item )
00088 {
00089 }
00090 #endif
00091
00092 template<class type> inline void QIntDict<type>::deleteItem( QPtrCollection::Item d )
00093 {
00094 if ( del_item ) delete (type*)d;
00095 }
00096
00097 template<class type>
00098 class QIntDictIterator : public QGDictIterator
00099 {
00100 public:
00101 QIntDictIterator(const QIntDict<type> &d) :QGDictIterator((QGDict &)d) {}
00102 ~QIntDictIterator() {}
00103 uint count() const { return dict->count(); }
00104 bool isEmpty() const { return dict->count() == 0; }
00105 type *toFirst() { return (type *)QGDictIterator::toFirst(); }
00106 operator type *() const { return (type *)QGDictIterator::get(); }
00107 type *current() const { return (type *)QGDictIterator::get(); }
00108 long currentKey() const { return QGDictIterator::getKeyInt(); }
00109 type *operator()() { return (type *)QGDictIterator::operator()(); }
00110 type *operator++() { return (type *)QGDictIterator::operator++(); }
00111 type *operator+=(uint j) { return (type *)QGDictIterator::operator+=(j);}
00112 };
00113
00114 #ifdef QT_QWINEXPORT
00115 #define Q_DEFINED_QINTDICT
00116 #include "qwinexport.h"
00117 #endif
00118 #endif // QINTDICT_H