~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to doc/html/q3ptrcollection.html

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-08-24 04:09:09 UTC
  • Revision ID: james.westby@ubuntu.com-20050824040909-xmxe9jfr4a0w5671
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?xml version="1.0" encoding="iso-8859-1"?>
 
2
<!DOCTYPE html
 
3
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
 
4
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 
5
<!-- /tmp/qt-4.0.0-espenr-1119621036935/qt-x11-opensource-desktop-4.0.0/src/qt3support/tools/q3ptrcollection.cpp -->
 
6
<head>
 
7
    <title>Qt 4.0: Q3PtrCollection Class Reference</title>
 
8
    <style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
 
9
a:link { color: #004faf; text-decoration: none }
 
10
a:visited { color: #672967; text-decoration: none }
 
11
td.postheader { font-family: sans-serif }
 
12
tr.address { font-family: sans-serif }
 
13
body { background: #ffffff; color: black; }</style>
 
14
</head>
 
15
<body>
 
16
<table border="0" cellpadding="0" cellspacing="0" width="100%">
 
17
<tr>
 
18
<td align="left" valign="top" width="32"><img src="images/qt-logo.png" align="left" width="32" height="32" border="0" /></td>
 
19
<td width="1">&nbsp;&nbsp;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&nbsp;&middot; <a href="classes.html"><font color="#004faf">All&nbsp;Classes</font></a>&nbsp;&middot; <a href="mainclasses.html"><font color="#004faf">Main&nbsp;Classes</font></a>&nbsp;&middot; <a href="annotated.html"><font color="#004faf">Annotated</font></a>&nbsp;&middot; <a href="groups.html"><font color="#004faf">Grouped&nbsp;Classes</font></a>&nbsp;&middot; <a href="functions.html"><font color="#004faf">Functions</font></a></td>
 
20
<td align="right" valign="top" width="230"><img src="images/trolltech-logo.png" align="right" width="203" height="32" border="0" /></td></tr></table><h1 align="center">Q3PtrCollection Class Reference</h1>
 
21
<p>The Q3PtrCollection class is the base class of most pointer-based Qt collections. <a href="#details">More...</a></p>
 
22
<pre>#include &lt;Q3PtrCollection&gt;</pre><p><b>This class is part of the Qt 3 support library.</b> It is provided to keep old source code working. We strongly advise against using it in new code. See the <a href="porting4.html">Porting Guide</a> for more information.</p>
 
23
<p>Part of the <a href="qt3support.html">Qt3Support</a> module.</p>
 
24
<p>Inherited by <a href="q3asciicache.html">Q3AsciiCache</a>, <a href="q3asciidict.html">Q3AsciiDict</a>, <a href="q3cache.html">Q3Cache</a>, <a href="q3dict.html">Q3Dict</a>, <a href="q3intcache.html">Q3IntCache</a>, <a href="q3intdict.html">Q3IntDict</a>, <a href="q3ptrdict.html">Q3PtrDict</a>, <a href="q3ptrlist.html">Q3PtrList</a>, <a href="q3ptrqueue.html">Q3PtrQueue</a>, <a href="q3ptrstack.html">Q3PtrStack</a>, and <a href="q3ptrvector.html">Q3PtrVector</a>.</p>
 
25
<p><b>Note:</b> All the functions in this class are <a href="threads.html#reentrant">reentrant</a>.</p>
 
26
<ul>
 
27
<li><a href="q3ptrcollection-members.html">List of all members, including inherited members</a></li>
 
28
</ul>
 
29
<a name="public-types"></a>
 
30
<h3>Public Types</h3>
 
31
<ul>
 
32
<li><div class="fn"/>typedef <b><a href="q3ptrcollection.html#Item-typedef">Item</a></b></li>
 
33
</ul>
 
34
<a name="public-functions"></a>
 
35
<h3>Public Functions</h3>
 
36
<ul>
 
37
<li><div class="fn"/>bool <b><a href="q3ptrcollection.html#autoDelete">autoDelete</a></b> () const</li>
 
38
<li><div class="fn"/>virtual void <b><a href="q3ptrcollection.html#clear">clear</a></b> () = 0</li>
 
39
<li><div class="fn"/>virtual uint <b><a href="q3ptrcollection.html#count">count</a></b> () const = 0</li>
 
40
<li><div class="fn"/>void <b><a href="q3ptrcollection.html#setAutoDelete">setAutoDelete</a></b> ( bool <i>enable</i> )</li>
 
41
</ul>
 
42
<a name="protected-functions"></a>
 
43
<h3>Protected Functions</h3>
 
44
<ul>
 
45
<li><div class="fn"/><b><a href="q3ptrcollection.html#Q3PtrCollection">Q3PtrCollection</a></b> ()</li>
 
46
<li><div class="fn"/><b><a href="q3ptrcollection.html#Q3PtrCollection-2">Q3PtrCollection</a></b> ( const Q3PtrCollection &amp; <i>source</i> )</li>
 
47
<li><div class="fn"/>virtual <b><a href="q3ptrcollection.html#dtor.Q3PtrCollection">~Q3PtrCollection</a></b> ()</li>
 
48
<li><div class="fn"/>virtual void <b><a href="q3ptrcollection.html#deleteItem">deleteItem</a></b> ( Item <i>d</i> ) = 0</li>
 
49
<li><div class="fn"/>virtual Item <b><a href="q3ptrcollection.html#newItem">newItem</a></b> ( Item <i>d</i> )</li>
 
50
</ul>
 
51
<a name="details"></a>
 
52
<hr />
 
53
<h2>Detailed Description</h2>
 
54
<p>The Q3PtrCollection class is the base class of most pointer-based Qt collections.</p>
 
55
<p>The Q3PtrCollection class is an abstract base class for the Qt collection classes QDict, <a href="q3ptrlist.html">Q3PtrList</a>, etc.</p>
 
56
<p>A Q3PtrCollection only knows about the number of objects in the collection and the deletion strategy (see <a href="q3ptrcollection.html#setAutoDelete">setAutoDelete</a>()).</p>
 
57
<p>A collection is implemented using the <tt>Item</tt> (generic collection item) type, which is a <tt>void*</tt>. The template classes that create the real collections cast the <tt>Item</tt> to the required type.</p>
 
58
<hr />
 
59
<h2>Member Type Documentation</h2>
 
60
<h3 class="fn"><a name="Item-typedef"></a>typedef Q3PtrCollection::Item</h3>
 
61
<p>This type is the generic &quot;item&quot; in a <a href="q3ptrcollection.html">Q3PtrCollection</a>.</p>
 
62
<hr />
 
63
<h2>Member Function Documentation</h2>
 
64
<h3 class="fn"><a name="Q3PtrCollection"></a>Q3PtrCollection::Q3PtrCollection ()&nbsp;&nbsp;<tt> [protected]</tt></h3>
 
65
<p>Constructs a collection. The constructor is protected because <a href="q3ptrcollection.html">Q3PtrCollection</a> is an abstract class.</p>
 
66
<h3 class="fn"><a name="Q3PtrCollection-2"></a>Q3PtrCollection::Q3PtrCollection ( const Q3PtrCollection &amp; <i>source</i> )&nbsp;&nbsp;<tt> [protected]</tt></h3>
 
67
<p>Constructs a copy of <i>source</i> with <a href="q3ptrcollection.html#autoDelete">autoDelete</a>() set to false. The constructor is protected because <a href="q3ptrcollection.html">Q3PtrCollection</a> is an abstract class.</p>
 
68
<p>Note that if <i>source</i> has autoDelete turned on, copying it will risk memory leaks, reading freed memory, or both.</p>
 
69
<h3 class="fn"><a name="dtor.Q3PtrCollection"></a>Q3PtrCollection::~Q3PtrCollection ()&nbsp;&nbsp;<tt> [virtual protected]</tt></h3>
 
70
<p>Destroys the collection. The destructor is protected because <a href="q3ptrcollection.html">Q3PtrCollection</a> is an abstract class.</p>
 
71
<h3 class="fn"><a name="autoDelete"></a>bool Q3PtrCollection::autoDelete () const</h3>
 
72
<p>Returns the setting of the auto-delete option. The default is false.</p>
 
73
<p>See also <a href="q3ptrcollection.html#setAutoDelete">setAutoDelete</a>().</p>
 
74
<h3 class="fn"><a name="clear"></a>void Q3PtrCollection::clear ()&nbsp;&nbsp;<tt> [pure virtual]</tt></h3>
 
75
<p>Removes all objects from the collection. The objects will be deleted if auto-delete has been enabled.</p>
 
76
<p>See also <a href="q3ptrcollection.html#setAutoDelete">setAutoDelete</a>().</p>
 
77
<h3 class="fn"><a name="count"></a><a href="qtglobal.html#uint-typedef">uint</a> Q3PtrCollection::count () const&nbsp;&nbsp;<tt> [pure virtual]</tt></h3>
 
78
<p>Returns the number of objects in the collection.</p>
 
79
<h3 class="fn"><a name="deleteItem"></a>void Q3PtrCollection::deleteItem ( <a href="q3ptrcollection.html#Item-typedef">Item</a> <i>d</i> )&nbsp;&nbsp;<tt> [pure virtual protected]</tt></h3>
 
80
<p>Reimplement this function if you want to be able to delete items.</p>
 
81
<p>Deletes an item that is about to be removed from the collection.</p>
 
82
<p>This function has to reimplemented in the collection template classes, and should <i>only</i> delete item <i>d</i> if auto-delete has been enabled.</p>
 
83
<p><b>Warning:</b> If you reimplement this function you must also reimplement the destructor and call the virtual function <a href="q3ptrcollection.html#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 deleteItem() function will not be called when the container is destroyed.</p>
 
84
<p>See also <a href="q3ptrcollection.html#newItem">newItem</a>() and <a href="q3ptrcollection.html#setAutoDelete">setAutoDelete</a>().</p>
 
85
<h3 class="fn"><a name="newItem"></a><a href="q3ptrcollection.html#Item-typedef">Item</a> Q3PtrCollection::newItem ( <a href="q3ptrcollection.html#Item-typedef">Item</a> <i>d</i> )&nbsp;&nbsp;<tt> [virtual protected]</tt></h3>
 
86
<p>Virtual function that creates a copy of an object that is about to be inserted into the collection.</p>
 
87
<p>The default implementation returns the <i>d</i> pointer, i.e. no copy is made.</p>
 
88
<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>
 
89
<p>See also <a href="q3ptrcollection.html#deleteItem">deleteItem</a>().</p>
 
90
<h3 class="fn"><a name="setAutoDelete"></a>void Q3PtrCollection::setAutoDelete ( bool <i>enable</i> )</h3>
 
91
<p>Sets the collection to auto-delete its contents if <i>enable</i> is true and to never delete them if <i>enable</i> is false.</p>
 
92
<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>
 
93
<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>
 
94
<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>
 
95
<p>See also <a href="q3ptrcollection.html#autoDelete">autoDelete</a>().</p>
 
96
<p /><address><hr /><div align="center">
 
97
<table width="100%" cellspacing="0" border="0"><tr class="address">
 
98
<td width="30%">Copyright &copy; 2005 <a href="trolltech.html">Trolltech</a></td>
 
99
<td width="40%" align="center"><a href="trademarks.html">Trademarks</a></td>
 
100
<td width="30%" align="right"><div align="right">Qt 4.0.0</div></td>
 
101
</tr></table></div></address></body>
 
102
</html>