<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- /home/espenr/tmp/qt - 3.3.8 - espenr - 2499/qt - x11 - free - 3.3.8/src/tools/tqptrcollection.cpp:40 -->
< html >
< head >
< meta http-equiv = "Content-Type" content = "text/html; charset=ISO-8859-1" >
< title > TQPtrCollection Class< / title >
< style type = "text/css" > < ! - -
fn { margin-left: 1cm; text-indent: -1cm; }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
body { background: #ffffff; color: black; }
-->< / style >
< / head >
< body >
< table border = "0" cellpadding = "0" cellspacing = "0" width = "100%" >
< tr bgcolor = "#E5E5E5" >
< td valign = center >
< a href = "index.html" >
< font color = "#004faf" > Home< / font > < / a >
| < a href = "classes.html" >
< font color = "#004faf" > All Classes< / font > < / a >
| < a href = "mainclasses.html" >
< font color = "#004faf" > Main Classes< / font > < / a >
| < a href = "annotated.html" >
< font color = "#004faf" > Annotated< / font > < / a >
| < a href = "groups.html" >
< font color = "#004faf" > Grouped Classes< / font > < / a >
| < a href = "functions.html" >
< font color = "#004faf" > Functions< / font > < / a >
< / td >
< td align = "right" valign = "center" > < img src = "logo32.png" align = "right" width = "64" height = "32" border = "0" > < / td > < / tr > < / table > < h1 align = center > TQPtrCollection Class Reference< / h1 >
< p > The TQPtrCollection class is the base class of most pointer-based TQt collections.
< a href = "#details" > More...< / a >
< p > All the functions in this class are < a href = "threads.html#reentrant" > reentrant< / a > when TQt is built with thread support.< / p >
< p > < tt > #include < < a href = "tqptrcollection-h.html" > tqptrcollection.h< / a > > < / tt >
< p > Inherited by < a href = "tqasciicache.html" > TQAsciiCache< / a > , < a href = "tqasciidict.html" > TQAsciiDict< / a > , < a href = "tqcache.html" > TQCache< / a > , < a href = "tqdict.html" > TQDict< / a > , < a href = "tqintcache.html" > TQIntCache< / a > , < a href = "tqintdict.html" > TQIntDict< / a > , < a href = "tqptrlist.html" > TQPtrList< / a > , < a href = "tqptrdict.html" > TQPtrDict< / a > , and < a href = "tqptrvector.html" > TQPtrVector< / a > .
< p > < a href = "tqptrcollection-members.html" > List of all member functions.< / a >
< h2 > Public Members< / h2 >
< ul >
< li class = fn > bool < a href = "#autoDelete" > < b > autoDelete< / b > < / a > () const< / li >
< li class = fn > void < a href = "#setAutoDelete" > < b > setAutoDelete< / b > < / a > ( bool enable )< / li >
< li class = fn > virtual uint < a href = "#count" > < b > count< / b > < / a > () const = 0< / li >
< li class = fn > virtual void < a href = "#clear" > < b > clear< / b > < / a > () = 0< / li >
< li class = fn > typedef void * < a href = "#Item" > < b > Item< / b > < / a > < / li >
< / ul >
< h2 > Protected Members< / h2 >
< ul >
< li class = fn > < a href = "#TQPtrCollection" > < b > TQPtrCollection< / b > < / a > ()< / li >
< li class = fn > < a href = "#TQPtrCollection-2" > < b > TQPtrCollection< / b > < / a > ( const TQPtrCollection & source )< / li >
< li class = fn > virtual < a href = "#~TQPtrCollection" > < b > ~TQPtrCollection< / b > < / a > ()< / li >
< li class = fn > virtual Item < a href = "#newItem" > < b > newItem< / b > < / a > ( Item d )< / li >
< li class = fn > virtual void < a href = "#deleteItem" > < b > deleteItem< / b > < / a > ( Item d ) = 0< / li >
< / ul >
< hr > < a name = "details" > < / a > < h2 > Detailed Description< / h2 >
The TQPtrCollection class is the base class of most pointer-based TQt collections.
< p >
< p > The TQPtrCollection class is an abstract base class for the TQt
< a href = "collection.html" > collection classes< / a > < a href = "tqdict.html" > TQDict< / a > , < a href = "tqptrlist.html" > TQPtrList< / a > ,
etc. TQt also includes value based collections, e.g. < a href = "tqvaluelist.html" > TQValueList< / a > ,
< a href = "tqmap.html" > TQMap< / a > , etc.
< p > A TQPtrCollection only knows about the number of objects in the
collection and the deletion strategy (see < a href = "#setAutoDelete" > setAutoDelete< / a > ()).
< p > A collection is implemented using the < a href = "#Item" > Item< / a > (generic collection
item) type, which is a < tt > void*< / tt > . The template classes that create
the real collections cast the < a href = "#Item" > Item< / a > to the required type.
< p > See also < a href = "collection.html" > Collection Classes< / a > and < a href = "tools.html" > Non-GUI Classes< / a > .
< hr > < h2 > Member Type Documentation< / h2 >
< h3 class = fn > < a name = "Item" > < / a > TQPtrCollection::Item< / h3 >
< p > This type is the generic "item" in a TQPtrCollection.
< hr > < h2 > Member Function Documentation< / h2 >
< h3 class = fn > < a name = "TQPtrCollection" > < / a > TQPtrCollection::TQPtrCollection ()< tt > [protected]< / tt >
< / h3 >
< p > Constructs a collection. The constructor is protected because
TQPtrCollection is an abstract class.
< h3 class = fn > < a name = "TQPtrCollection-2" > < / a > TQPtrCollection::TQPtrCollection ( const < a href = "tqptrcollection.html" > TQPtrCollection< / a > & source )< tt > [protected]< / tt >
< / h3 >
< p > Constructs a copy of < em > source< / em > with < a href = "#autoDelete" > autoDelete< / a > () set to FALSE. The
constructor is protected because TQPtrCollection is an abstract
class.
< p > Note that if < em > source< / em > has autoDelete turned on, copying it will
risk memory leaks, reading freed memory, or both.
< h3 class = fn > < a name = "~TQPtrCollection" > < / a > TQPtrCollection::~TQPtrCollection ()< tt > [virtual protected]< / tt >
< / h3 >
< p > Destroys the collection. The destructor is protected because
TQPtrCollection is an abstract class.
< h3 class = fn > bool < a name = "autoDelete" > < / a > TQPtrCollection::autoDelete () const
< / h3 >
< p > Returns the setting of the auto-delete option. The default is FALSE.
< p > < p > See also < a href = "#setAutoDelete" > setAutoDelete< / a > ().
< h3 class = fn > void < a name = "clear" > < / a > TQPtrCollection::clear ()< tt > [pure virtual]< / tt >
< / h3 >
< p > Removes all objects from the collection. The objects will be
deleted if auto-delete has been enabled.
< p > < p > See also < a href = "#setAutoDelete" > setAutoDelete< / a > ().
< p > Reimplemented in < a href = "tqasciicache.html#clear" > TQAsciiCache< / a > , < a href = "tqasciidict.html#clear" > TQAsciiDict< / a > , < a href = "tqcache.html#clear" > TQCache< / a > , < a href = "tqdict.html#clear" > TQDict< / a > , < a href = "tqintcache.html#clear" > TQIntCache< / a > , < a href = "tqintdict.html#clear" > TQIntDict< / a > , < a href = "tqptrlist.html#clear" > TQPtrList< / a > , < a href = "tqptrdict.html#clear" > TQPtrDict< / a > , and < a href = "tqptrvector.html#clear" > TQPtrVector< / a > .
< h3 class = fn > uint < a name = "count" > < / a > TQPtrCollection::count () const< tt > [pure virtual]< / tt >
< / h3 >
< p > Returns the number of objects in the collection.
< p > Reimplemented in < a href = "tqasciicache.html#count" > TQAsciiCache< / a > , < a href = "tqasciidict.html#count" > TQAsciiDict< / a > , < a href = "tqcache.html#count" > TQCache< / a > , < a href = "tqdict.html#count" > TQDict< / a > , < a href = "tqintcache.html#count" > TQIntCache< / a > , < a href = "tqintdict.html#count" > TQIntDict< / a > , < a href = "tqptrlist.html#count" > TQPtrList< / a > , < a href = "tqptrdict.html#count" > TQPtrDict< / a > , and < a href = "tqptrvector.html#count" > TQPtrVector< / a > .
< h3 class = fn > void < a name = "deleteItem" > < / a > TQPtrCollection::deleteItem ( < a href = "tqptrcollection.html#Item" > Item< / a > d )< tt > [pure virtual protected]< / tt >
< / h3 >
< p > Reimplement this function if you want to be able to delete items.
< p > Deletes an item that is about to be removed from the collection.
< p > This function has to reimplemented in the collection template
classes, and should < em > only< / em > delete item < em > d< / em > if auto-delete has
been enabled.
< p > < b > Warning:< / b > If you reimplement this function you must also
reimplement the destructor and call the virtual function < a href = "#clear" > clear< / a > ()
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
< a href = "#deleteItem" > deleteItem< / a > () function will not be called when the container is
destroyed.
< p > < p > See also < a href = "#newItem" > newItem< / a > () and < a href = "#setAutoDelete" > setAutoDelete< / a > ().
< h3 class = fn > < a href = "tqptrcollection.html#Item" > Item< / a > < a name = "newItem" > < / a > TQPtrCollection::newItem ( < a href = "tqptrcollection.html#Item" > Item< / a > d )< tt > [virtual protected]< / tt >
< / h3 >
Virtual function that creates a copy of an object that is about to
be inserted into the collection.
< p > The default implementation returns the < em > d< / em > pointer, i.e. no copy
is made.
< p > This function is seldom reimplemented in the collection template
classes. It is not common practice to make a copy of something
that is being inserted.
< p > < p > See also < a href = "#deleteItem" > deleteItem< / a > ().
< h3 class = fn > void < a name = "setAutoDelete" > < / a > TQPtrCollection::setAutoDelete ( bool enable )
< / h3 >
< p > Sets the collection to auto-delete its contents if < em > enable< / em > is
TRUE and to never delete them if < em > enable< / em > is FALSE.
< p > If auto-deleting is turned on, all the items in a collection are
deleted when the collection itself is deleted. This is convenient
if the collection has the only pointer to the items.
< p > The default setting is FALSE, for safety. If you turn it on, be
careful about copying the collection - you might find yourself
with two collections deleting the same items.
< p > Note that the auto-delete setting may also affect other functions
in subclasses. For example, a subclass that has a remove()
function will remove the item from its data structure, and if
auto-delete is enabled, will also delete the item.
< p > < p > See also < a href = "#autoDelete" > autoDelete< / a > ().
< p > Examples: < a href = "grapher-nsplugin-example.html#x2769" > grapher/grapher.cpp< / a > , < a href = "scribble-example.html#x924" > scribble/scribble.cpp< / a > , and < a href = "bigtable-example.html#x1291" > table/bigtable/main.cpp< / a > .
<!-- eof -->
< hr > < p >
This file is part of the < a href = "index.html" > TQt toolkit< / a > .
Copyright © 1995-2007
< a href = "http://www.trolltech.com/" > Trolltech< / a > . All Rights Reserved.< p > < address > < hr > < div align = center >
< table width = 100% cellspacing = 0 border = 0 > < tr >
< td > Copyright © 2007
< a href = "troll.html" > Trolltech< / a > < td align = center > < a href = "trademarks.html" > Trademarks< / a >
< td align = right > < div align = right > TQt 3.3.8< / div >
< / table > < / div > < / address > < / body >
< / html >