Public Member Functions | Private Member Functions | List of all members
QPtrDict< type > Class Template Reference

#include <qptrdict.h>

Inheritance diagram for QPtrDict< type >:
QGDict QCollection

Public Member Functions

 QPtrDict (int size=17)
 
 QPtrDict (const QPtrDict< type > &d)
 
 ~QPtrDict ()
 
QPtrDict< type > & operator= (const QPtrDict< type > &d)
 
uint count () const
 
uint size () const
 
bool isEmpty () const
 
void insert (void *k, const type *d)
 
void replace (void *k, const type *d)
 
bool remove (void *k)
 
typetake (void *k)
 
typefind (void *k) const
 
typeoperator[] (void *k) const
 
void clear ()
 
void resize (uint n)
 
void statistics () const
 
- Public Member Functions inherited from QGDict
uint size () const
 
QCollection::Item look_string (const QString &key, QCollection::Item, int)
 
QCollection::Item look_ascii (const char *key, QCollection::Item, int)
 
QCollection::Item look_int (long key, QCollection::Item, int)
 
QCollection::Item look_ptr (void *key, QCollection::Item, int)
 
QDataStreamread (QDataStream &)
 
QDataStreamwrite (QDataStream &) const
 
- Public Member Functions inherited from QCollection
bool autoDelete () const
 
void setAutoDelete (bool enable)
 

Private Member Functions

void deleteItem (Item d)
 
template<>
void deleteItem (QCollection::Item)
 

Additional Inherited Members

- Public Types inherited from QCollection
typedef void * Item
 
- Protected Types inherited from QGDict
enum  KeyType { StringKey, AsciiKey, IntKey, PtrKey }
 
- Protected Member Functions inherited from QGDict
 QGDict (uint len, KeyType kt, bool cs, bool ck)
 
 QGDict (const QGDict &)
 
 ~QGDict ()
 
QGDictoperator= (const QGDict &)
 
bool remove_string (const QString &key, QCollection::Item item=0)
 
bool remove_ascii (const char *key, QCollection::Item item=0)
 
bool remove_int (long key, QCollection::Item item=0)
 
bool remove_ptr (void *key, QCollection::Item item=0)
 
QCollection::Item take_string (const QString &key)
 
QCollection::Item take_ascii (const char *key)
 
QCollection::Item take_int (long key)
 
QCollection::Item take_ptr (void *key)
 
void resize (uint)
 
int hashKeyString (const QString &)
 
int hashKeyAscii (const char *)
 
void statistics () const
 
virtual QDataStreamread (QDataStream &, QCollection::Item &)
 
virtual QDataStreamwrite (QDataStream &, QCollection::Item) const
 
- Protected Member Functions inherited from QCollection
 QCollection ()
 
 QCollection (const QCollection &)
 
virtual ~QCollection ()
 
virtual Item newItem (Item)
 
- Protected Attributes inherited from QCollection
bool del_item
 

Detailed Description

template<class type>
class QPtrDict< type >

Definition at line 46 of file qptrdict.h.

Constructor & Destructor Documentation

template<class type>
QPtrDict< type >::QPtrDict ( int  size = 17)
inline

Definition at line 49 of file qptrdict.h.

49 : QGDict(size,PtrKey,0,0) {}
QGDict(uint len, KeyType kt, bool cs, bool ck)
Definition: qgdict.cpp:222
uint size() const
Definition: qptrdict.h:55
template<class type>
QPtrDict< type >::QPtrDict ( const QPtrDict< type > &  d)
inline

Definition at line 50 of file qptrdict.h.

50 : QGDict(d) {}
QGDict(uint len, KeyType kt, bool cs, bool ck)
Definition: qgdict.cpp:222
template<class type>
QPtrDict< type >::~QPtrDict ( )
inline

Definition at line 51 of file qptrdict.h.

51 { clear(); }
void clear()
Definition: qptrdict.h:67

Member Function Documentation

template<class type>
void QPtrDict< type >::clear ( )
inlinevirtual

Removes all objects from the collection. The objects will be deleted if auto-delete has been enabled.

See also
setAutoDelete()

Reimplemented from QGDict.

Definition at line 67 of file qptrdict.h.

67 { QGDict::clear(); }
void clear()
Definition: qgdict.cpp:857
template<class type>
uint QPtrDict< type >::count ( ) const
inlinevirtual

Returns the number of objects in the collection.

Reimplemented from QGDict.

Definition at line 54 of file qptrdict.h.

54 { return QGDict::count(); }
uint count() const
Definition: qgdict.h:107
template<class type >
void QPtrDict< type >::deleteItem ( QCollection::Item  d)
inlineprivatevirtual

Virtual function that deletes an item that is about to be removed from the collection.

The default implementation deletes d pointer if and only if auto-delete has been enabled.

This function is always reimplemented in the collection template classes.

Warning
If you reimplement this function you must also reimplement the destructor and call the virtual function clear() from your destructor. This is due to the way virtual functions and destructors work in C++: virtual functions in derived classes cannot be called from a destructor. If you do not do this your deleteItem() function will not be called when the container is destructed.
See also
newItem(), setAutoDelete()

Reimplemented from QCollection.

Definition at line 80 of file qptrdict.h.

81 {
82  if ( del_item ) delete (type *)d;
83 }
bool del_item
Definition: qcollection.h:67
template<>
void QPtrDict< void >::deleteItem ( QCollection::Item  d)
inlineprivatevirtual

Virtual function that deletes an item that is about to be removed from the collection.

The default implementation deletes d pointer if and only if auto-delete has been enabled.

This function is always reimplemented in the collection template classes.

Warning
If you reimplement this function you must also reimplement the destructor and call the virtual function clear() from your destructor. This is due to the way virtual functions and destructors work in C++: virtual functions in derived classes cannot be called from a destructor. If you do not do this your deleteItem() function will not be called when the container is destructed.
See also
newItem(), setAutoDelete()

Reimplemented from QCollection.

Definition at line 75 of file qptrdict.h.

76 {
77 }
template<class type>
type* QPtrDict< type >::find ( void *  k) const
inline

Definition at line 63 of file qptrdict.h.

64  { return (type *)((QGDict*)this)->QGDict::look_ptr(k,0,0); }
The QGDict class is an internal class for implementing QDict template classes.
Definition: qgdict.h:104
template<class type>
void QPtrDict< type >::insert ( void *  k,
const type d 
)
inline

Definition at line 57 of file qptrdict.h.

58  { QGDict::look_ptr(k,(Item)d,1); }
QCollection::Item look_ptr(void *key, QCollection::Item, int)
Definition: qgdict.cpp:492
void * Item
Definition: qcollection.h:60
template<class type>
bool QPtrDict< type >::isEmpty ( ) const
inline

Definition at line 56 of file qptrdict.h.

56 { return QGDict::count() == 0; }
uint count() const
Definition: qgdict.h:107
template<class type>
QPtrDict<type>& QPtrDict< type >::operator= ( const QPtrDict< type > &  d)
inline

Definition at line 52 of file qptrdict.h.

53  { return (QPtrDict<type>&)QGDict::operator=(d); }
QGDict & operator=(const QGDict &)
Definition: qgdict.cpp:309
template<class type>
type* QPtrDict< type >::operator[] ( void *  k) const
inline

Definition at line 65 of file qptrdict.h.

66  { return (type *)((QGDict*)this)->QGDict::look_ptr(k,0,0); }
The QGDict class is an internal class for implementing QDict template classes.
Definition: qgdict.h:104
template<class type>
bool QPtrDict< type >::remove ( void *  k)
inline

Definition at line 61 of file qptrdict.h.

61 { return QGDict::remove_ptr(k); }
bool remove_ptr(void *key, QCollection::Item item=0)
Definition: qgdict.cpp:775
template<class type>
void QPtrDict< type >::replace ( void *  k,
const type d 
)
inline

Definition at line 59 of file qptrdict.h.

60  { QGDict::look_ptr(k,(Item)d,2); }
QCollection::Item look_ptr(void *key, QCollection::Item, int)
Definition: qgdict.cpp:492
void * Item
Definition: qcollection.h:60
template<class type>
void QPtrDict< type >::resize ( uint  n)
inline

Definition at line 68 of file qptrdict.h.

68 { QGDict::resize(n); }
void resize(uint)
Definition: qgdict.cpp:527
std::void_t< T > n
template<class type>
uint QPtrDict< type >::size ( ) const
inline

Definition at line 55 of file qptrdict.h.

55 { return QGDict::size(); }
uint size() const
Definition: qgdict.h:108
template<class type>
void QPtrDict< type >::statistics ( ) const
inline

Definition at line 69 of file qptrdict.h.

69 { QGDict::statistics(); }
void statistics() const
Definition: qgdict.cpp:930
template<class type>
type* QPtrDict< type >::take ( void *  k)
inline

Definition at line 62 of file qptrdict.h.

62 { return (type*)QGDict::take_ptr(k); }
QCollection::Item take_ptr(void *key)
Definition: qgdict.cpp:838

The documentation for this class was generated from the following file: