<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en_US" lang="en_US"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <!-- q3ptrvector.qdoc --> <title>Qt 4.8: Q3PtrVector Class Reference</title> <link rel="stylesheet" type="text/css" href="style/style.css" /> <script src="scripts/jquery.js" type="text/javascript"></script> <script src="scripts/functions.js" type="text/javascript"></script> <link rel="stylesheet" type="text/css" href="style/superfish.css" /> <link rel="stylesheet" type="text/css" href="style/narrow.css" /> <!--[if IE]> <meta name="MSSmartTagsPreventParsing" content="true"> <meta http-equiv="imagetoolbar" content="no"> <![endif]--> <!--[if lt IE 7]> <link rel="stylesheet" type="text/css" href="style/style_ie6.css"> <![endif]--> <!--[if IE 7]> <link rel="stylesheet" type="text/css" href="style/style_ie7.css"> <![endif]--> <!--[if IE 8]> <link rel="stylesheet" type="text/css" href="style/style_ie8.css"> <![endif]--> <script src="scripts/superfish.js" type="text/javascript"></script> <script src="scripts/narrow.js" type="text/javascript"></script> </head> <body class="" onload="CheckEmptyAndLoadList();"> <div class="header" id="qtdocheader"> <div class="content"> <div id="nav-logo"> <a href="index.html">Home</a></div> <a href="index.html" class="qtref"><span>Qt Reference Documentation</span></a> <div id="narrowsearch"></div> <div id="nav-topright"> <ul> <li class="nav-topright-home"><a href="http://qt.digia.com/">Qt HOME</a></li> <li class="nav-topright-dev"><a href="http://qt-project.org/">DEV</a></li> <li class="nav-topright-doc nav-topright-doc-active"><a href="http://qt-project.org/doc/"> DOC</a></li> <li class="nav-topright-blog"><a href="http://blog.qt.digia.com/">BLOG</a></li> </ul> </div> <div id="shortCut"> <ul> <li class="shortCut-topleft-inactive"><span><a href="index.html">Qt 4.8</a></span></li> <li class="shortCut-topleft-active"><a href="http://qt-project.org/doc/">ALL VERSIONS </a></li> </ul> </div> <ul class="sf-menu" id="narrowmenu"> <li><a href="#">API Lookup</a> <ul> <li><a href="classes.html">Class index</a></li> <li><a href="functions.html">Function index</a></li> <li><a href="modules.html">Modules</a></li> <li><a href="namespaces.html">Namespaces</a></li> <li><a href="qtglobal.html">Global Declarations</a></li> <li><a href="qdeclarativeelements.html">QML elements</a></li> </ul> </li> <li><a href="#">Qt Topics</a> <ul> <li><a href="qt-basic-concepts.html">Programming with Qt</a></li> <li><a href="qtquick.html">Device UIs & Qt Quick</a></li> <li><a href="qt-gui-concepts.html">UI Design with Qt</a></li> <li><a href="supported-platforms.html">Supported Platforms</a></li> <li><a href="technology-apis.html">Qt and Key Technologies</a></li> <li><a href="best-practices.html">How-To's and Best Practices</a></li> </ul> </li> <li><a href="#">Examples</a> <ul> <li><a href="all-examples.html">Examples</a></li> <li><a href="tutorials.html">Tutorials</a></li> <li><a href="demos.html">Demos</a></li> <li><a href="qdeclarativeexamples.html">QML Examples</a></li> </ul> </li> </ul> </div> </div> <div class="wrapper"> <div class="hd"> <span></span> </div> <div class="bd group"> <div class="sidebar"> <div class="searchlabel"> Search index:</div> <div class="search" id="sidebarsearch"> <form id="qtdocsearch" action="" onsubmit="return false;"> <fieldset> <input type="text" name="searchstring" id="pageType" value="" /> <div id="resultdialog"> <a href="#" id="resultclose">Close</a> <p id="resultlinks" class="all"><a href="#" id="showallresults">All</a> | <a href="#" id="showapiresults">API</a> | <a href="#" id="showarticleresults">Articles</a> | <a href="#" id="showexampleresults">Examples</a></p> <p id="searchcount" class="all"><span id="resultcount"></span><span id="apicount"></span><span id="articlecount"></span><span id="examplecount"></span> results:</p> <ul id="resultlist" class="all"> </ul> </div> </fieldset> </form> </div> <div class="box first bottombar" id="lookup"> <h2 title="API Lookup"><span></span> API Lookup</h2> <div id="list001" class="list"> <ul id="ul001" > <li class="defaultLink"><a href="classes.html">Class index</a></li> <li class="defaultLink"><a href="functions.html">Function index</a></li> <li class="defaultLink"><a href="modules.html">Modules</a></li> <li class="defaultLink"><a href="namespaces.html">Namespaces</a></li> <li class="defaultLink"><a href="qtglobal.html">Global Declarations</a></li> <li class="defaultLink"><a href="qdeclarativeelements.html">QML elements</a></li> </ul> </div> </div> <div class="box bottombar" id="topics"> <h2 title="Qt Topics"><span></span> Qt Topics</h2> <div id="list002" class="list"> <ul id="ul002" > <li class="defaultLink"><a href="qt-basic-concepts.html">Programming with Qt</a></li> <li class="defaultLink"><a href="qtquick.html">Device UIs & Qt Quick</a></li> <li class="defaultLink"><a href="qt-gui-concepts.html">UI Design with Qt</a></li> <li class="defaultLink"><a href="supported-platforms.html">Supported Platforms</a></li> <li class="defaultLink"><a href="technology-apis.html">Qt and Key Technologies</a></li> <li class="defaultLink"><a href="best-practices.html">How-To's and Best Practices</a></li> </ul> </div> </div> <div class="box" id="examples"> <h2 title="Examples"><span></span> Examples</h2> <div id="list003" class="list"> <ul id="ul003"> <li class="defaultLink"><a href="all-examples.html">Examples</a></li> <li class="defaultLink"><a href="tutorials.html">Tutorials</a></li> <li class="defaultLink"><a href="demos.html">Demos</a></li> <li class="defaultLink"><a href="qdeclarativeexamples.html">QML Examples</a></li> </ul> </div> </div> </div> <div class="wrap"> <div class="toolbar"> <div class="breadcrumb toolblock"> <ul> <li class="first"><a href="index.html">Home</a></li> <!-- Breadcrumbs go here --> <li><a href="modules.html">Modules</a></li> <li>Qt3SupportLight</li> <li>Q3PtrVector</li> </ul> </div> <div class="toolbuttons toolblock"> <ul> <li id="smallA" class="t_button">A</li> <li id="medA" class="t_button active">A</li> <li id="bigA" class="t_button">A</li> <li id="print" class="t_button"><a href="javascript:this.print();"> <span>Print</span></a></li> </ul> </div> </div> <div class="content mainContent"> <div class="toc"> <h3><a name="toc">Contents</a></h3> <ul> <li class="level1"><a href="#public-functions">Public Functions</a></li> <li class="level1"><a href="#protected-functions">Protected Functions</a></li> <li class="level1"><a href="#details">Detailed Description</a></li> </ul> </div> <h1 class="title">Q3PtrVector Class Reference</h1> <!-- $$$Q3PtrVector-brief --> <p>The Q3PtrVector class is a template collection class that provides a vector (array). <a href="#details">More...</a></p> <!-- @@@Q3PtrVector --> <pre class="cpp"> <span class="preprocessor">#include <Q3PtrVector></span></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 <a href="porting4.html">Porting to Qt 4</a> for more information.</p> <p><b>Inherits: </b><a href="q3ptrcollection.html">Q3PtrCollection</a>.</p> <ul> <li><a href="q3ptrvector-members.html">List of all members, including inherited members</a></li> </ul> <a name="public-functions"></a> <h2>Public Functions</h2> <table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="q3ptrvector.html#Q3PtrVector">Q3PtrVector</a></b> ()</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="q3ptrvector.html#Q3PtrVector-2">Q3PtrVector</a></b> ( uint <i>size</i> )</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="q3ptrvector.html#Q3PtrVector-3">Q3PtrVector</a></b> ( const Q3PtrVector<type> & <i>v</i> )</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="q3ptrvector.html#dtor.Q3PtrVector">~Q3PtrVector</a></b> ()</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> type * </td><td class="memItemRight bottomAlign"><b><a href="q3ptrvector.html#at">at</a></b> ( uint <i>i</i> ) const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="q3ptrvector.html#bsearch">bsearch</a></b> ( const type * <i>d</i> ) const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> uint </td><td class="memItemRight bottomAlign"><b><a href="q3ptrvector.html#contains">contains</a></b> ( const type * <i>d</i> ) const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> uint </td><td class="memItemRight bottomAlign"><b><a href="q3ptrvector.html#containsRef">containsRef</a></b> ( const type * <i>d</i> ) const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> type ** </td><td class="memItemRight bottomAlign"><b><a href="q3ptrvector.html#data">data</a></b> () const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="q3ptrvector.html#fill">fill</a></b> ( const type * <i>d</i>, int <i>size</i> = -1 )</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="q3ptrvector.html#find">find</a></b> ( const type * <i>d</i>, uint <i>i</i> = 0 ) const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="q3ptrvector.html#findRef">findRef</a></b> ( const type * <i>d</i>, uint <i>i</i> = 0 ) const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="q3ptrvector.html#insert">insert</a></b> ( uint <i>i</i>, const type * <i>d</i> )</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="q3ptrvector.html#isEmpty">isEmpty</a></b> () const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="q3ptrvector.html#isNull">isNull</a></b> () const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="q3ptrvector.html#remove">remove</a></b> ( uint <i>i</i> )</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="q3ptrvector.html#resize">resize</a></b> ( uint <i>size</i> )</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> uint </td><td class="memItemRight bottomAlign"><b><a href="q3ptrvector.html#size">size</a></b> () const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="q3ptrvector.html#sort">sort</a></b> ()</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> type * </td><td class="memItemRight bottomAlign"><b><a href="q3ptrvector.html#take">take</a></b> ( uint <i>i</i> )</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> Q3PtrVector<type> & </td><td class="memItemRight bottomAlign"><b><a href="q3ptrvector.html#operator-eq">operator=</a></b> ( const Q3PtrVector<type> & <i>v</i> )</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="q3ptrvector.html#operator-eq-eq">operator==</a></b> ( const Q3PtrVector<type> & <i>v</i> ) const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> type * </td><td class="memItemRight bottomAlign"><b><a href="q3ptrvector.html#operator-5b-5d">operator[]</a></b> ( int <i>i</i> ) const</td></tr> </table> <a name="reimplemented-public-functions"></a> <h2>Reimplemented Public Functions</h2> <table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="q3ptrvector.html#clear">clear</a></b> ()</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> virtual uint </td><td class="memItemRight bottomAlign"><b><a href="q3ptrvector.html#count">count</a></b> () const</td></tr> </table> <ul> <li class="fn">4 public functions inherited from <a href="q3ptrcollection.html#public-functions">Q3PtrCollection</a></li> </ul> <a name="protected-functions"></a> <h2>Protected Functions</h2> <table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> virtual int </td><td class="memItemRight bottomAlign"><b><a href="q3ptrvector.html#compareItems">compareItems</a></b> ( Q3PtrCollection::Item <i>d1</i>, Q3PtrCollection::Item <i>d2</i> )</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> virtual QDataStream & </td><td class="memItemRight bottomAlign"><b><a href="q3ptrvector.html#read">read</a></b> ( QDataStream & <i>s</i>, Q3PtrCollection::Item & <i>item</i> )</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> virtual QDataStream & </td><td class="memItemRight bottomAlign"><b><a href="q3ptrvector.html#write">write</a></b> ( QDataStream & <i>s</i>, Q3PtrCollection::Item <i>item</i> ) const</td></tr> </table> <ul> <li class="fn">2 protected functions inherited from <a href="q3ptrcollection.html#protected-functions">Q3PtrCollection</a></li> </ul> <a name="details"></a> <!-- $$$Q3PtrVector-description --> <div class="descr"> <h2>Detailed Description</h2> <p>The Q3PtrVector class is a template collection class that provides a vector (array).</p> <p><a href="q3valuevector.html">Q3ValueVector</a> is an STL-compatible alternative to this class.</p> <p>Q3PtrVector is implemented as a template class. Defines a template instance Q3PtrVector<X> to create a vector that contains pointers to X (X*).</p> <p>A vector is the same as an array. The main difference between Q3PtrVector and <a href="q3memarray.html">Q3MemArray</a> is that Q3PtrVector stores pointers to the elements, whereas <a href="q3memarray.html">Q3MemArray</a> stores the elements themselves (i.e. <a href="q3memarray.html">Q3MemArray</a> is value-based and Q3PtrVector is pointer-based).</p> <p>Items are added to the vector using <a href="q3ptrvector.html#insert">insert</a>() or <a href="q3ptrvector.html#fill">fill</a>(). Items are removed with <a href="q3ptrvector.html#remove">remove</a>(). You can get a pointer to an item at a particular index position using <a href="q3ptrvector.html#at">at</a>().</p> <p>Unless otherwise stated, all functions that remove items from the vector will also delete the element pointed to if <a href="q3ptrcollection.html#setAutoDelete">auto-deletion</a> is enabled. By default, auto-deletion is disabled; see <a href="q3ptrcollection.html#setAutoDelete">setAutoDelete</a>(). This behavior can be changed in a subclass by reimplementing the virtual function <a href="q3ptrcollection.html#deleteItem">deleteItem</a>().</p> <p>Functions that compare items (<a href="q3ptrvector.html#find">find</a>() and <a href="q3ptrvector.html#sort">sort</a>() for example) will do so using the virtual function <a href="q3ptrvector.html#compareItems">compareItems</a>(). The default implementation of this function only compares the pointer values. Reimplement <a href="q3ptrvector.html#compareItems">compareItems</a>() in a subclass to get searching and sorting based on the item contents. You can perform a linear search for a pointer in the vector using <a href="q3ptrvector.html#findRef">findRef</a>(), or a binary search (of a sorted vector) using <a href="q3ptrvector.html#bsearch">bsearch</a>(). You can count the number of times an item appears in the vector with <a href="q3ptrvector.html#contains">contains</a>() or <a href="q3ptrvector.html#containsRef">containsRef</a>().</p> </div> <p><b>See also </b><a href="q3memarray.html">Q3MemArray</a>.</p> <!-- @@@Q3PtrVector --> <div class="func"> <h2>Member Function Documentation</h2> <!-- $$$Q3PtrVector[overload1]$$$Q3PtrVector --> <h3 class="fn"><a name="Q3PtrVector"></a>Q3PtrVector::<span class="name">Q3PtrVector</span> ()</h3> <p>Constructs a null vector.</p> <p><b>See also </b><a href="q3ptrvector.html#isNull">isNull</a>().</p> <!-- @@@Q3PtrVector --> <!-- $$$Q3PtrVector$$$Q3PtrVectoruint --> <h3 class="fn"><a name="Q3PtrVector-2"></a>Q3PtrVector::<span class="name">Q3PtrVector</span> ( <span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> <i>size</i> )</h3> <p>Constructs an vector with room for <i>size</i> items. Makes a null vector if <i>size</i> == 0.</p> <p>All <i>size</i> positions in the vector are initialized to 0.</p> <p><b>See also </b><a href="q3ptrvector.html#size">size</a>(), <a href="q3ptrvector.html#resize">resize</a>(), and <a href="q3ptrvector.html#isNull">isNull</a>().</p> <!-- @@@Q3PtrVector --> <!-- $$$Q3PtrVector$$$Q3PtrVectorconstQ3PtrVector<type>& --> <h3 class="fn"><a name="Q3PtrVector-3"></a>Q3PtrVector::<span class="name">Q3PtrVector</span> ( const <span class="type">Q3PtrVector</span><<span class="type">type</span>> & <i>v</i> )</h3> <p>Constructs a copy of <i>v</i>. Only the pointers are copied (i.e. shallow copy).</p> <!-- @@@Q3PtrVector --> <!-- $$$~Q3PtrVector[overload1]$$$~Q3PtrVector --> <h3 class="fn"><a name="dtor.Q3PtrVector"></a>Q3PtrVector::<span class="name">~Q3PtrVector</span> ()</h3> <p>Removes all items from the vector, and destroys the vector itself.</p> <p><b>See also </b><a href="q3ptrvector.html#clear">clear</a>().</p> <!-- @@@~Q3PtrVector --> <!-- $$$at[overload1]$$$atuint --> <h3 class="fn"><a name="at"></a><span class="type">type</span> * Q3PtrVector::<span class="name">at</span> ( <span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> <i>i</i> ) const</h3> <p>Returns the item at position <i>i</i>, or 0 if there is no item at that position. <i>i</i> must be less than <a href="q3ptrvector.html#size">size</a>().</p> <!-- @@@at --> <!-- $$$bsearch[overload1]$$$bsearchconsttype* --> <h3 class="fn"><a name="bsearch"></a><span class="type">int</span> Q3PtrVector::<span class="name">bsearch</span> ( const <span class="type">type</span> * <i>d</i> ) const</h3> <p>In a sorted array, finds the first occurrence of <i>d</i> using a binary search. For a sorted array, this is generally much faster than <a href="q3ptrvector.html#find">find</a>(), which performs a linear search.</p> <p>Returns the position of <i>d</i>, or -1 if <i>d</i> could not be found. <i>d</i> must not be 0.</p> <p>Compares items using the virtual function <a href="q3ptrvector.html#compareItems">compareItems</a>().</p> <p><b>See also </b><a href="q3ptrvector.html#sort">sort</a>() and <a href="q3ptrvector.html#find">find</a>().</p> <!-- @@@bsearch --> <!-- $$$clear[overload1]$$$clear --> <h3 class="fn"><a name="clear"></a><span class="type">void</span> Q3PtrVector::<span class="name">clear</span> ()<tt> [virtual]</tt></h3> <p>Reimplemented from <a href="q3ptrcollection.html#clear">Q3PtrCollection::clear</a>().</p> <p>Removes all items from the vector, and destroys the vector itself.</p> <p>The vector becomes a null vector.</p> <p><b>See also </b><a href="q3ptrvector.html#isNull">isNull</a>().</p> <!-- @@@clear --> <!-- $$$compareItems[overload1]$$$compareItemsQ3PtrCollection::ItemQ3PtrCollection::Item --> <h3 class="fn"><a name="compareItems"></a><span class="type">int</span> Q3PtrVector::<span class="name">compareItems</span> ( <span class="type"><a href="q3ptrcollection.html#Item-typedef">Q3PtrCollection::Item</a></span> <i>d1</i>, <span class="type"><a href="q3ptrcollection.html#Item-typedef">Q3PtrCollection::Item</a></span> <i>d2</i> )<tt> [virtual protected]</tt></h3> <p>This virtual function compares two list items.</p> <p>Returns:</p> <ul> <li>zero if <i>d1</i> == <i>d2</i></li> <li>nonzero if <i>d1</i> != <i>d2</i></li> </ul> <p>This function returns <i>int</i> rather than <i>bool</i> so that reimplementations can return one of three values and use it to sort by:</p> <ul> <li>0 if <i>d1</i> == <i>d2</i></li> <li>> 0 (positive integer) if <i>d1</i> > <i>d2</i></li> <li>< 0 (negative integer) if <i>d1</i> < <i>d2</i></li> </ul> <p>The <a href="q3ptrvector.html#sort">sort</a>() and <a href="q3ptrvector.html#bsearch">bsearch</a>() functions require compareItems() to be implemented as described here.</p> <p>This function should not modify the vector because some const functions call compareItems().</p> <!-- @@@compareItems --> <!-- $$$contains[overload1]$$$containsconsttype* --> <h3 class="fn"><a name="contains"></a><span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> Q3PtrVector::<span class="name">contains</span> ( const <span class="type">type</span> * <i>d</i> ) const</h3> <p>Returns the number of occurrences of item <i>d</i> in the vector.</p> <p>Compares items using the virtual function <a href="q3ptrvector.html#compareItems">compareItems</a>().</p> <p><b>See also </b><a href="q3ptrvector.html#containsRef">containsRef</a>().</p> <!-- @@@contains --> <!-- $$$containsRef[overload1]$$$containsRefconsttype* --> <h3 class="fn"><a name="containsRef"></a><span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> Q3PtrVector::<span class="name">containsRef</span> ( const <span class="type">type</span> * <i>d</i> ) const</h3> <p>Returns the number of occurrences of the item pointer <i>d</i> in the vector.</p> <p>This function does <i>not</i> use <a href="q3ptrvector.html#compareItems">compareItems</a>() to compare items.</p> <p><b>See also </b><a href="q3ptrvector.html#findRef">findRef</a>().</p> <!-- @@@containsRef --> <!-- $$$count[overload1]$$$count --> <h3 class="fn"><a name="count"></a><span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> Q3PtrVector::<span class="name">count</span> () const<tt> [virtual]</tt></h3> <p>Reimplemented from <a href="q3ptrcollection.html#count">Q3PtrCollection::count</a>().</p> <p>Returns the number of items in the vector. The vector is empty if count() == 0.</p> <p><b>See also </b><a href="q3ptrvector.html#isEmpty">isEmpty</a>(), <a href="q3ptrvector.html#size">size</a>(), and <a href="q3ptrvector.html#isNull">isNull</a>().</p> <!-- @@@count --> <!-- $$$data[overload1]$$$data --> <h3 class="fn"><a name="data"></a><span class="type">type</span> ** Q3PtrVector::<span class="name">data</span> () const</h3> <p>Returns a pointer to the actual vector data, which is an array of type*.</p> <p>The vector is a null vector if data() == 0 (null pointer).</p> <p><b>See also </b><a href="q3ptrvector.html#isNull">isNull</a>().</p> <!-- @@@data --> <!-- $$$fill[overload1]$$$fillconsttype*int --> <h3 class="fn"><a name="fill"></a><span class="type">bool</span> Q3PtrVector::<span class="name">fill</span> ( const <span class="type">type</span> * <i>d</i>, <span class="type">int</span> <i>size</i> = -1 )</h3> <p>Inserts item <i>d</i> in all positions in the vector. Any existing items are removed. If <i>d</i> is 0, the vector becomes empty.</p> <p>If <i>size</i> >= 0, the vector is first resized to <i>size</i>. By default, <i>size</i> is -1.</p> <p>Returns true if successful, i.e. <i>size</i> is the same as the current size, or <i>size</i> is larger and the memory has successfully been allocated; otherwise returns false.</p> <p><b>See also </b><a href="q3ptrvector.html#resize">resize</a>(), <a href="q3ptrvector.html#insert">insert</a>(), and <a href="q3ptrvector.html#isEmpty">isEmpty</a>().</p> <!-- @@@fill --> <!-- $$$find[overload1]$$$findconsttype*uint --> <h3 class="fn"><a name="find"></a><span class="type">int</span> Q3PtrVector::<span class="name">find</span> ( const <span class="type">type</span> * <i>d</i>, <span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> <i>i</i> = 0 ) const</h3> <p>Finds the first occurrence of item <i>d</i> in the vector using a linear search. The search starts at position <i>i</i>, which must be less than <a href="q3ptrvector.html#size">size</a>(). <i>i</i> is by default 0; i.e. the search starts at the start of the vector.</p> <p>Returns the position of <i>d</i>, or -1 if <i>d</i> could not be found.</p> <p>Compares items using the virtual function <a href="q3ptrvector.html#compareItems">compareItems</a>().</p> <p>Use the much faster <a href="q3ptrvector.html#bsearch">bsearch</a>() to search a sorted vector.</p> <p><b>See also </b><a href="q3ptrvector.html#findRef">findRef</a>() and <a href="q3ptrvector.html#bsearch">bsearch</a>().</p> <!-- @@@find --> <!-- $$$findRef[overload1]$$$findRefconsttype*uint --> <h3 class="fn"><a name="findRef"></a><span class="type">int</span> Q3PtrVector::<span class="name">findRef</span> ( const <span class="type">type</span> * <i>d</i>, <span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> <i>i</i> = 0 ) const</h3> <p>Finds the first occurrence of the item pointer <i>d</i> in the vector using a linear search. The search starts at position <i>i</i>, which must be less than <a href="q3ptrvector.html#size">size</a>(). <i>i</i> is by default 0; i.e. the search starts at the start of the vector.</p> <p>Returns the position of <i>d</i>, or -1 if <i>d</i> could not be found.</p> <p>This function does <i>not</i> use <a href="q3ptrvector.html#compareItems">compareItems</a>() to compare items.</p> <p>Use the much faster <a href="q3ptrvector.html#bsearch">bsearch</a>() to search a sorted vector.</p> <p><b>See also </b><a href="q3ptrvector.html#find">find</a>() and <a href="q3ptrvector.html#bsearch">bsearch</a>().</p> <!-- @@@findRef --> <!-- $$$insert[overload1]$$$insertuintconsttype* --> <h3 class="fn"><a name="insert"></a><span class="type">bool</span> Q3PtrVector::<span class="name">insert</span> ( <span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> <i>i</i>, const <span class="type">type</span> * <i>d</i> )</h3> <p>Sets position <i>i</i> in the vector to contain the item <i>d</i>. <i>i</i> must be less than <a href="q3ptrvector.html#size">size</a>(). Any previous element in position <i>i</i> is removed.</p> <p>Returns true if <i>i</i> is within range; otherwise returns false.</p> <p><b>See also </b><a href="q3ptrvector.html#at">at</a>().</p> <!-- @@@insert --> <!-- $$$isEmpty[overload1]$$$isEmpty --> <h3 class="fn"><a name="isEmpty"></a><span class="type">bool</span> Q3PtrVector::<span class="name">isEmpty</span> () const</h3> <p>Returns true if the vector is empty; otherwise returns false.</p> <p><b>See also </b><a href="q3ptrvector.html#count">count</a>().</p> <!-- @@@isEmpty --> <!-- $$$isNull[overload1]$$$isNull --> <h3 class="fn"><a name="isNull"></a><span class="type">bool</span> Q3PtrVector::<span class="name">isNull</span> () const</h3> <p>Returns true if the vector is null; otherwise returns false.</p> <p>A null vector has <a href="q3ptrvector.html#size">size</a>() == 0 and <a href="q3ptrvector.html#data">data</a>() == 0.</p> <p><b>See also </b><a href="q3ptrvector.html#size">size</a>().</p> <!-- @@@isNull --> <!-- $$$read[overload1]$$$readQDataStream&Q3PtrCollection::Item& --> <h3 class="fn"><a name="read"></a><span class="type"><a href="qdatastream.html">QDataStream</a></span> & Q3PtrVector::<span class="name">read</span> ( <span class="type"><a href="qdatastream.html">QDataStream</a></span> & <i>s</i>, <span class="type"><a href="q3ptrcollection.html#Item-typedef">Q3PtrCollection::Item</a></span> & <i>item</i> )<tt> [virtual protected]</tt></h3> <p>Reads a vector item, <i>item</i>, from the stream <i>s</i> and returns a reference to the stream.</p> <p>The default implementation sets <i>item</i> to 0.</p> <p><b>See also </b><a href="q3ptrvector.html#write">write</a>().</p> <!-- @@@read --> <!-- $$$remove[overload1]$$$removeuint --> <h3 class="fn"><a name="remove"></a><span class="type">bool</span> Q3PtrVector::<span class="name">remove</span> ( <span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> <i>i</i> )</h3> <p>Removes the item at position <i>i</i> in the vector, if there is one. <i>i</i> must be less than <a href="q3ptrvector.html#size">size</a>().</p> <p>Returns true if <i>i</i> is within range; otherwise returns false.</p> <p><b>See also </b><a href="q3ptrvector.html#take">take</a>() and <a href="q3ptrvector.html#at">at</a>().</p> <!-- @@@remove --> <!-- $$$resize[overload1]$$$resizeuint --> <h3 class="fn"><a name="resize"></a><span class="type">bool</span> Q3PtrVector::<span class="name">resize</span> ( <span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> <i>size</i> )</h3> <p>Resizes (expands or shrinks) the vector to <i>size</i> elements. The vector becomes a null vector if <i>size</i> == 0.</p> <p>Any items at position <i>size</i> or beyond in the vector are removed. New positions are initialized to 0.</p> <p>Returns true if successful, i.e. if the memory was successfully allocated; otherwise returns false.</p> <p><b>See also </b><a href="q3ptrvector.html#size">size</a>() and <a href="q3ptrvector.html#isNull">isNull</a>().</p> <!-- @@@resize --> <!-- $$$size[overload1]$$$size --> <h3 class="fn"><a name="size"></a><span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> Q3PtrVector::<span class="name">size</span> () const</h3> <p>Returns the size of the vector, i.e. the number of vector positions. This is also the maximum number of items the vector can hold.</p> <p>The vector is a null vector if size() == 0.</p> <p><b>See also </b><a href="q3ptrvector.html#isNull">isNull</a>(), <a href="q3ptrvector.html#resize">resize</a>(), and <a href="q3ptrvector.html#count">count</a>().</p> <!-- @@@size --> <!-- $$$sort[overload1]$$$sort --> <h3 class="fn"><a name="sort"></a><span class="type">void</span> Q3PtrVector::<span class="name">sort</span> ()</h3> <p>Sorts the items in ascending order. Any empty positions will be put last.</p> <p>Compares items using the virtual function <a href="q3ptrvector.html#compareItems">compareItems</a>().</p> <p><b>See also </b><a href="q3ptrvector.html#bsearch">bsearch</a>().</p> <!-- @@@sort --> <!-- $$$take[overload1]$$$takeuint --> <h3 class="fn"><a name="take"></a><span class="type">type</span> * Q3PtrVector::<span class="name">take</span> ( <span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> <i>i</i> )</h3> <p>Returns the item at position <i>i</i> in the vector, and removes that item from the vector. <i>i</i> must be less than <a href="q3ptrvector.html#size">size</a>(). If there is no item at position <i>i</i>, 0 is returned.</p> <p>Unlike <a href="q3ptrvector.html#remove">remove</a>(), this function does <i>not</i> call <a href="q3ptrcollection.html#deleteItem">deleteItem</a>() for the removed item.</p> <p><b>See also </b><a href="q3ptrvector.html#remove">remove</a>() and <a href="q3ptrvector.html#at">at</a>().</p> <!-- @@@take --> <!-- $$$write[overload1]$$$writeQDataStream&Q3PtrCollection::Item --> <h3 class="fn"><a name="write"></a><span class="type"><a href="qdatastream.html">QDataStream</a></span> & Q3PtrVector::<span class="name">write</span> ( <span class="type"><a href="qdatastream.html">QDataStream</a></span> & <i>s</i>, <span class="type"><a href="q3ptrcollection.html#Item-typedef">Q3PtrCollection::Item</a></span> <i>item</i> ) const<tt> [virtual protected]</tt></h3> <p>Writes a vector item, <i>item</i>, to the stream <i>s</i> and returns a reference to the stream.</p> <p>The default implementation does nothing.</p> <p><b>See also </b><a href="q3ptrvector.html#read">read</a>().</p> <!-- @@@write --> <!-- $$$operator=[overload1]$$$operator=constQ3PtrVector<type>& --> <h3 class="fn"><a name="operator-eq"></a><span class="type">Q3PtrVector</span><<span class="type">type</span>> & Q3PtrVector::<span class="name">operator=</span> ( const <span class="type">Q3PtrVector</span><<span class="type">type</span>> & <i>v</i> )</h3> <p>Assigns <i>v</i> to this vector and returns a reference to this vector.</p> <p>This vector is first cleared and then all the items from <i>v</i> are copied into the vector. Only the pointers are copied (i.e. shallow copy).</p> <p><b>See also </b><a href="q3ptrvector.html#clear">clear</a>().</p> <!-- @@@operator= --> <!-- $$$operator==[overload1]$$$operator==constQ3PtrVector<type>& --> <h3 class="fn"><a name="operator-eq-eq"></a><span class="type">bool</span> Q3PtrVector::<span class="name">operator==</span> ( const <span class="type">Q3PtrVector</span><<span class="type">type</span>> & <i>v</i> ) const</h3> <p>Returns true if this vector and <i>v</i> are equal; otherwise returns false.</p> <!-- @@@operator== --> <!-- $$$operator[][overload1]$$$operator[]int --> <h3 class="fn"><a name="operator-5b-5d"></a><span class="type">type</span> * Q3PtrVector::<span class="name">operator[]</span> ( <span class="type">int</span> <i>i</i> ) const</h3> <p>Returns the item at position <i>i</i>, or 0 if there is no item at that position. <i>i</i> must be less than <a href="q3ptrvector.html#size">size</a>().</p> <p>Equivalent to at(<i>i</i>).</p> <p><b>See also </b><a href="q3ptrvector.html#at">at</a>().</p> <!-- @@@operator[] --> </div> </div> </div> </div> <div class="ft"> <span></span> </div> </div> <div class="footer"> <p> <acronym title="Copyright">©</acronym> 2013 Digia Plc and/or its subsidiaries. Documentation contributions included herein are the copyrights of their respective owners.</p> <br /> <p> The documentation provided herein is licensed under the terms of the <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation License version 1.3</a> as published by the Free Software Foundation.</p> <p> Documentation sources may be obtained from <a href="http://www.qt-project.org"> www.qt-project.org</a>.</p> <br /> <p> Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide. All other trademarks are property of their respective owners. <a title="Privacy Policy" href="http://en.gitorious.org/privacy_policy/">Privacy Policy</a></p> </div> <script src="scripts/functions.js" type="text/javascript"></script> </body> </html>