Sophie

Sophie

distrib > Mageia > 7 > x86_64 > by-pkgid > 1dd17e0d683ef79b4bb6872bbf359d7f > files > 6975

qt4-doc-4.8.7-26.2.mga7.noarch.rpm

<?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" />
<!-- qvarlengtharray.qdoc -->
  <title>Qt 4.8: QVarLengthArray 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 &amp; 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>&nbsp;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 &amp; 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><a href="qtcore.html">QtCore</a></li>
<li>QVarLengthArray</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-types">Public Types</a></li>
<li class="level1"><a href="#public-functions">Public Functions</a></li>
<li class="level1"><a href="#related-non-members">Related Non-Members</a></li>
<li class="level1"><a href="#details">Detailed Description</a></li>
</ul>
</div>
<h1 class="title">QVarLengthArray Class Reference</h1>
<!-- $$$QVarLengthArray-brief -->
<p>The QVarLengthArray class provides a low-level variable-length array. <a href="#details">More...</a></p>
<!-- @@@QVarLengthArray -->
<pre class="cpp"> <span class="preprocessor">#include &lt;QVarLengthArray&gt;</span></pre><p><b>Note:</b> All functions in this class are <a href="threads-reentrancy.html#reentrant">reentrant</a>.</p>
<ul>
<li><a href="qvarlengtharray-members.html">List of all members, including inherited members</a></li>
</ul>
<a name="public-types"></a>
<h2>Public Types</h2>
<table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> typedef </td><td class="memItemRight bottomAlign"><b><a href="qvarlengtharray.html#const_iterator-typedef">const_iterator</a></b></td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> typedef </td><td class="memItemRight bottomAlign"><b><a href="qvarlengtharray.html#const_pointer-typedef">const_pointer</a></b></td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> typedef </td><td class="memItemRight bottomAlign"><b><a href="qvarlengtharray.html#const_reference-typedef">const_reference</a></b></td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> typedef </td><td class="memItemRight bottomAlign"><b><a href="qvarlengtharray.html#difference_type-typedef">difference_type</a></b></td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> typedef </td><td class="memItemRight bottomAlign"><b><a href="qvarlengtharray.html#iterator-typedefx">iterator</a></b></td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> typedef </td><td class="memItemRight bottomAlign"><b><a href="qvarlengtharray.html#pointer-typedef">pointer</a></b></td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> typedef </td><td class="memItemRight bottomAlign"><b><a href="qvarlengtharray.html#reference-typedef">reference</a></b></td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> typedef </td><td class="memItemRight bottomAlign"><b><a href="qvarlengtharray.html#size_type-typedef">size_type</a></b></td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> typedef </td><td class="memItemRight bottomAlign"><b><a href="qvarlengtharray.html#value_type-typedef">value_type</a></b></td></tr>
</table>
<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="qvarlengtharray.html#QVarLengthArray">QVarLengthArray</a></b> ( int <i>size</i> = 0 )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qvarlengtharray.html#QVarLengthArray-2">QVarLengthArray</a></b> ( const QVarLengthArray&lt;T, Prealloc&gt; &amp; <i>other</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qvarlengtharray.html#dtor.QVarLengthArray">~QVarLengthArray</a></b> ()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qvarlengtharray.html#append">append</a></b> ( const T &amp; <i>t</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qvarlengtharray.html#append-2">append</a></b> ( const T * <i>buf</i>, int <i>size</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> const T &amp; </td><td class="memItemRight bottomAlign"><b><a href="qvarlengtharray.html#at">at</a></b> ( int <i>i</i> ) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> iterator </td><td class="memItemRight bottomAlign"><b><a href="qvarlengtharray.html#begin">begin</a></b> ()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> const_iterator </td><td class="memItemRight bottomAlign"><b><a href="qvarlengtharray.html#begin-2">begin</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qvarlengtharray.html#capacity">capacity</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qvarlengtharray.html#clear">clear</a></b> ()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> const_iterator </td><td class="memItemRight bottomAlign"><b><a href="qvarlengtharray.html#constBegin">constBegin</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> const T * </td><td class="memItemRight bottomAlign"><b><a href="qvarlengtharray.html#constData">constData</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> const_iterator </td><td class="memItemRight bottomAlign"><b><a href="qvarlengtharray.html#constEnd">constEnd</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qvarlengtharray.html#count">count</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> T * </td><td class="memItemRight bottomAlign"><b><a href="qvarlengtharray.html#data">data</a></b> ()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> const T * </td><td class="memItemRight bottomAlign"><b><a href="qvarlengtharray.html#data-2">data</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> iterator </td><td class="memItemRight bottomAlign"><b><a href="qvarlengtharray.html#end">end</a></b> ()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> const_iterator </td><td class="memItemRight bottomAlign"><b><a href="qvarlengtharray.html#end-2">end</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> iterator </td><td class="memItemRight bottomAlign"><b><a href="qvarlengtharray.html#erase">erase</a></b> ( iterator <i>pos</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> iterator </td><td class="memItemRight bottomAlign"><b><a href="qvarlengtharray.html#erase-2">erase</a></b> ( iterator <i>begin</i>, iterator <i>end</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qvarlengtharray.html#insert">insert</a></b> ( int <i>i</i>, const T &amp; <i>value</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> iterator </td><td class="memItemRight bottomAlign"><b><a href="qvarlengtharray.html#insert-2">insert</a></b> ( iterator <i>before</i>, int <i>count</i>, const T &amp; <i>value</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qvarlengtharray.html#insert-3">insert</a></b> ( int <i>i</i>, int <i>count</i>, const T &amp; <i>value</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> iterator </td><td class="memItemRight bottomAlign"><b><a href="qvarlengtharray.html#insert-4">insert</a></b> ( iterator <i>before</i>, const T &amp; <i>value</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qvarlengtharray.html#isEmpty">isEmpty</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qvarlengtharray.html#prepend">prepend</a></b> ( const T &amp; <i>value</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qvarlengtharray.html#remove">remove</a></b> ( int <i>i</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qvarlengtharray.html#remove-2">remove</a></b> ( int <i>i</i>, int <i>count</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qvarlengtharray.html#removeLast">removeLast</a></b> ()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qvarlengtharray.html#replace">replace</a></b> ( int <i>i</i>, const T &amp; <i>value</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qvarlengtharray.html#reserve">reserve</a></b> ( int <i>size</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qvarlengtharray.html#resize">resize</a></b> ( int <i>size</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qvarlengtharray.html#size">size</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> T </td><td class="memItemRight bottomAlign"><b><a href="qvarlengtharray.html#value">value</a></b> ( int <i>i</i> ) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> T </td><td class="memItemRight bottomAlign"><b><a href="qvarlengtharray.html#value-2">value</a></b> ( int <i>i</i>, const T &amp; <i>defaultValue</i> ) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QVarLengthArray&lt;T, Prealloc&gt; &amp; </td><td class="memItemRight bottomAlign"><b><a href="qvarlengtharray.html#operator-2b-eq">operator+=</a></b> ( const T &amp; <i>value</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QVarLengthArray&lt;T, Prealloc&gt; &amp; </td><td class="memItemRight bottomAlign"><b><a href="qvarlengtharray.html#operator-lt-lt">operator&lt;&lt;</a></b> ( const T &amp; <i>value</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QVarLengthArray&lt;T, Prealloc&gt; &amp; </td><td class="memItemRight bottomAlign"><b><a href="qvarlengtharray.html#operator-eq">operator=</a></b> ( const QVarLengthArray&lt;T, Prealloc&gt; &amp; <i>other</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> T &amp; </td><td class="memItemRight bottomAlign"><b><a href="qvarlengtharray.html#operator-5b-5d">operator[]</a></b> ( int <i>i</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> const T &amp; </td><td class="memItemRight bottomAlign"><b><a href="qvarlengtharray.html#operator-5b-5d-2">operator[]</a></b> ( int <i>i</i> ) const</td></tr>
</table>
<a name="related-non-members"></a>
<h2>Related Non-Members</h2>
<table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qvarlengtharray.html#operator-not-eq-32">operator!=</a></b> ( const QVarLengthArray&lt;T, Prealloc1&gt; &amp; <i>left</i>, const QVarLengthArray&lt;T, Prealloc2&gt; &amp; <i>right</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qvarlengtharray.html#operator-eq-eq-34">operator==</a></b> ( const QVarLengthArray&lt;T, Prealloc1&gt; &amp; <i>left</i>, const QVarLengthArray&lt;T, Prealloc2&gt; &amp; <i>right</i> )</td></tr>
</table>
<a name="details"></a>
<!-- $$$QVarLengthArray-description -->
<div class="descr">
<h2>Detailed Description</h2>
<p>The QVarLengthArray class provides a low-level variable-length array.</p>
<p>The C++ language doesn't support variable-length arrays on the stack. For example, the following code won't compile:</p>
<pre class="cpp"> <span class="type">int</span> myfunc(<span class="type">int</span> n)
 {
     <span class="type">int</span> table<span class="operator">[</span>n <span class="operator">+</span> <span class="number">1</span><span class="operator">]</span>;  <span class="comment">// WRONG</span>
     <span class="operator">.</span><span class="operator">.</span><span class="operator">.</span>
     <span class="keyword">return</span> table<span class="operator">[</span>n<span class="operator">]</span>;
 }</pre>
<p>The alternative is to allocate the array on the heap (with <tt>new</tt>):</p>
<pre class="cpp"> <span class="type">int</span> myfunc(<span class="type">int</span> n)
 {
     <span class="type">int</span> <span class="operator">*</span>table <span class="operator">=</span> <span class="keyword">new</span> <span class="type">int</span><span class="operator">[</span>n <span class="operator">+</span> <span class="number">1</span><span class="operator">]</span>;
     <span class="operator">.</span><span class="operator">.</span><span class="operator">.</span>
     <span class="type">int</span> ret <span class="operator">=</span> table<span class="operator">[</span>n<span class="operator">]</span>;
     <span class="keyword">delete</span><span class="operator">[</span><span class="operator">]</span> table;
     <span class="keyword">return</span> ret;
 }</pre>
<p>However, if myfunc() is called very frequently from the application's inner loop, heap allocation can be a major source of slowdown.</p>
<p>QVarLengthArray is an attempt to work around this gap in the C++ language. It allocates a certain number of elements on the stack, and if you resize the array to a larger size, it automatically uses the heap instead. Stack allocation has the advantage that it is much faster than heap allocation.</p>
<p>Example:</p>
<pre class="cpp"> <span class="type">int</span> myfunc(<span class="type">int</span> n)
 {
     <span class="type">QVarLengthArray</span><span class="operator">&lt;</span><span class="type">int</span><span class="operator">,</span> <span class="number">1024</span><span class="operator">&gt;</span> array(n <span class="operator">+</span> <span class="number">1</span>);
     <span class="operator">.</span><span class="operator">.</span><span class="operator">.</span>
     <span class="keyword">return</span> array<span class="operator">[</span>n<span class="operator">]</span>;
 }</pre>
<p>In the example above, QVarLengthArray will preallocate 1024 elements on the stack and use them unless <tt>n + 1</tt> is greater than 1024. If you omit the second template argument, QVarLengthArray's default of 256 is used.</p>
<p>QVarLengthArray's value type must be an <a href="containers.html#assignable-data-type">assignable data type</a>. This covers most data types that are commonly used, but the compiler won't let you, for example, store a <a href="qwidget.html">QWidget</a> as a value; instead, store a <a href="qwidget.html">QWidget</a> *.</p>
<p>QVarLengthArray, like <a href="qvector.html">QVector</a>, provides a resizable array data structure. The main differences between the two classes are:</p>
<ul>
<li>QVarLengthArray's API is much more low-level. It provides no iterators and lacks much of <a href="qvector.html">QVector</a>'s functionality.</li>
<li>QVarLengthArray doesn't initialize the memory if the value is a basic type. (<a href="qvector.html">QVector</a> always does.)</li>
<li><a href="qvector.html">QVector</a> uses <a href="implicit-sharing.html">implicit sharing</a> as a memory optimization. QVarLengthArray doesn't provide that feature; however, it usually produces slightly better performance due to reduced overhead, especially in tight loops.</li>
</ul>
<p>In summary, QVarLengthArray is a low-level optimization class that only makes sense in very specific cases. It is used a few places inside Qt and was added to Qt's public API for the convenience of advanced users.</p>
</div>
<p><b>See also </b><a href="qvector.html">QVector</a>, <a href="qlist.html">QList</a>, and <a href="qlinkedlist.html">QLinkedList</a>.</p>
<!-- @@@QVarLengthArray -->
<div class="types">
<h2>Member Type Documentation</h2>
<!-- $$$const_iterator -->
<h3 class="fn"><a name="const_iterator-typedef"></a>typedef QVarLengthArray::<span class="name">const_iterator</span></h3>
<p>Typedef for const T *. Provided for STL compatibility.</p>
<p>This typedef was introduced in Qt 4.7.</p>
<!-- @@@const_iterator -->
<!-- $$$const_pointer -->
<h3 class="fn"><a name="const_pointer-typedef"></a>typedef QVarLengthArray::<span class="name">const_pointer</span></h3>
<p>Typedef for const T *. Provided for STL compatibility.</p>
<p>This typedef was introduced in Qt 4.7.</p>
<!-- @@@const_pointer -->
<!-- $$$const_reference -->
<h3 class="fn"><a name="const_reference-typedef"></a>typedef QVarLengthArray::<span class="name">const_reference</span></h3>
<p>Typedef for const T &amp;. Provided for STL compatibility.</p>
<p>This typedef was introduced in Qt 4.7.</p>
<!-- @@@const_reference -->
<!-- $$$difference_type -->
<h3 class="fn"><a name="difference_type-typedef"></a>typedef QVarLengthArray::<span class="name">difference_type</span></h3>
<p>Typedef for ptrdiff_t. Provided for STL compatibility.</p>
<p>This typedef was introduced in Qt 4.7.</p>
<!-- @@@difference_type -->
<!-- $$$iterator -->
<h3 class="fn"><a name="iterator-typedefx"></a>typedef QVarLengthArray::<span class="name">iterator</span></h3>
<p>Typedef for T *. Provided for STL compatibility.</p>
<p>This typedef was introduced in Qt 4.7.</p>
<!-- @@@iterator -->
<!-- $$$pointer -->
<h3 class="fn"><a name="pointer-typedef"></a>typedef QVarLengthArray::<span class="name">pointer</span></h3>
<p>Typedef for T *. Provided for STL compatibility.</p>
<p>This typedef was introduced in Qt 4.7.</p>
<!-- @@@pointer -->
<!-- $$$reference -->
<h3 class="fn"><a name="reference-typedef"></a>typedef QVarLengthArray::<span class="name">reference</span></h3>
<p>Typedef for T &amp;. Provided for STL compatibility.</p>
<p>This typedef was introduced in Qt 4.7.</p>
<!-- @@@reference -->
<!-- $$$size_type -->
<h3 class="fn"><a name="size_type-typedef"></a>typedef QVarLengthArray::<span class="name">size_type</span></h3>
<p>Typedef for int. Provided for STL compatibility.</p>
<p>This typedef was introduced in Qt 4.7.</p>
<!-- @@@size_type -->
<!-- $$$value_type -->
<h3 class="fn"><a name="value_type-typedef"></a>typedef QVarLengthArray::<span class="name">value_type</span></h3>
<p>Typedef for T. Provided for STL compatibility.</p>
<p>This typedef was introduced in Qt 4.7.</p>
<!-- @@@value_type -->
</div>
<div class="func">
<h2>Member Function Documentation</h2>
<!-- $$$QVarLengthArray[overload1]$$$QVarLengthArrayint -->
<h3 class="fn"><a name="QVarLengthArray"></a>QVarLengthArray::<span class="name">QVarLengthArray</span> ( <span class="type">int</span> <i>size</i> = 0 )</h3>
<p>Constructs an array with an initial size of <i>size</i> elements.</p>
<p>If the value type is a primitive type (e.g&#x2e;, char, int, float) or a pointer type (e.g&#x2e;, <a href="qwidget.html">QWidget</a> *), the elements are not initialized. For other types, the elements are initialized with a <a href="containers.html#default-constructed-values">default-constructed value</a>.</p>
<!-- @@@QVarLengthArray -->
<!-- $$$QVarLengthArray$$$QVarLengthArrayconstQVarLengthArray<T,Prealloc>& -->
<h3 class="fn"><a name="QVarLengthArray-2"></a>QVarLengthArray::<span class="name">QVarLengthArray</span> ( const <span class="type">QVarLengthArray</span>&lt;<span class="type">T</span>, <span class="type">Prealloc</span>&gt; &amp; <i>other</i> )</h3>
<p>Constructs a copy of <i>other</i>.</p>
<!-- @@@QVarLengthArray -->
<!-- $$$~QVarLengthArray[overload1]$$$~QVarLengthArray -->
<h3 class="fn"><a name="dtor.QVarLengthArray"></a>QVarLengthArray::<span class="name">~QVarLengthArray</span> ()</h3>
<p>Destroys the array.</p>
<!-- @@@~QVarLengthArray -->
<!-- $$$append[overload1]$$$appendconstT& -->
<h3 class="fn"><a name="append"></a><span class="type">void</span> QVarLengthArray::<span class="name">append</span> ( const <span class="type">T</span> &amp; <i>t</i> )</h3>
<p>Appends item <i>t</i> to the array, extending the array if necessary.</p>
<p><b>See also </b><a href="qvarlengtharray.html#removeLast">removeLast</a>().</p>
<!-- @@@append -->
<!-- $$$append$$$appendconstT*int -->
<h3 class="fn"><a name="append-2"></a><span class="type">void</span> QVarLengthArray::<span class="name">append</span> ( const <span class="type">T</span> * <i>buf</i>, <span class="type">int</span> <i>size</i> )</h3>
<p>Appends <i>size</i> amount of items referenced by <i>buf</i> to this array.</p>
<!-- @@@append -->
<!-- $$$at[overload1]$$$atint -->
<h3 class="fn"><a name="at"></a>const <span class="type">T</span> &amp; QVarLengthArray::<span class="name">at</span> ( <span class="type">int</span> <i>i</i> ) const</h3>
<p>Returns a reference to the item at index position <i>i</i>.</p>
<p><i>i</i> must be a valid index position in the array (i.e&#x2e;, 0 &lt;= <i>i</i> &lt; <a href="qvarlengtharray.html#size">size</a>()).</p>
<p><b>See also </b><a href="qvarlengtharray.html#value">value</a>() and <a href="qvarlengtharray.html#operator-5b-5d">operator[]</a>().</p>
<!-- @@@at -->
<!-- $$$begin[overload1]$$$begin -->
<h3 class="fn"><a name="begin"></a><span class="type"><a href="qvarlengtharray.html#iterator-typedefx">iterator</a></span> QVarLengthArray::<span class="name">begin</span> ()</h3>
<p>Returns an <a href="containers.html#stl-style-iterators">STL-style iterator</a> pointing to the first item in the array.</p>
<p>This function was introduced in Qt 4.8.</p>
<p><b>See also </b><a href="qvarlengtharray.html#constBegin">constBegin</a>() and <a href="qvarlengtharray.html#end">end</a>().</p>
<!-- @@@begin -->
<!-- $$$begin$$$begin -->
<h3 class="fn"><a name="begin-2"></a><span class="type"><a href="qvarlengtharray.html#const_iterator-typedef">const_iterator</a></span> QVarLengthArray::<span class="name">begin</span> () const</h3>
<p>This is an overloaded function.</p>
<p>This function was introduced in Qt 4.8.</p>
<!-- @@@begin -->
<!-- $$$capacity[overload1]$$$capacity -->
<h3 class="fn"><a name="capacity"></a><span class="type">int</span> QVarLengthArray::<span class="name">capacity</span> () const</h3>
<p>Returns the maximum number of elements that can be stored in the array without forcing a reallocation.</p>
<p>The sole purpose of this function is to provide a means of fine tuning <a href="qvarlengtharray.html">QVarLengthArray</a>'s memory usage. In general, you will rarely ever need to call this function. If you want to know how many items are in the array, call <a href="qvarlengtharray.html#size">size</a>().</p>
<p><b>See also </b><a href="qvarlengtharray.html#reserve">reserve</a>().</p>
<!-- @@@capacity -->
<!-- $$$clear[overload1]$$$clear -->
<h3 class="fn"><a name="clear"></a><span class="type">void</span> QVarLengthArray::<span class="name">clear</span> ()</h3>
<p>Removes all the elements from the array.</p>
<p>Same as resize(0).</p>
<!-- @@@clear -->
<!-- $$$constBegin[overload1]$$$constBegin -->
<h3 class="fn"><a name="constBegin"></a><span class="type"><a href="qvarlengtharray.html#const_iterator-typedef">const_iterator</a></span> QVarLengthArray::<span class="name">constBegin</span> () const</h3>
<p>Returns a const <a href="containers.html#stl-style-iterators">STL-style iterator</a> pointing to the first item in the array.</p>
<p>This function was introduced in Qt 4.8.</p>
<p><b>See also </b><a href="qvarlengtharray.html#begin">begin</a>() and <a href="qvarlengtharray.html#constEnd">constEnd</a>().</p>
<!-- @@@constBegin -->
<!-- $$$constData[overload1]$$$constData -->
<h3 class="fn"><a name="constData"></a>const <span class="type">T</span> * QVarLengthArray::<span class="name">constData</span> () const</h3>
<p>Returns a const pointer to the data stored in the array. The pointer can be used to access the items in the array. The pointer remains valid as long as the array isn't reallocated.</p>
<p>This function is mostly useful to pass an array to a function that accepts a plain C++ array.</p>
<p><b>See also </b><a href="qvarlengtharray.html#data">data</a>() and <a href="qvarlengtharray.html#operator-5b-5d">operator[]</a>().</p>
<!-- @@@constData -->
<!-- $$$constEnd[overload1]$$$constEnd -->
<h3 class="fn"><a name="constEnd"></a><span class="type"><a href="qvarlengtharray.html#const_iterator-typedef">const_iterator</a></span> QVarLengthArray::<span class="name">constEnd</span> () const</h3>
<p>Returns a const <a href="containers.html#stl-style-iterators">STL-style iterator</a> pointing to the imaginary item after the last item in the array.</p>
<p>This function was introduced in Qt 4.8.</p>
<p><b>See also </b><a href="qvarlengtharray.html#constBegin">constBegin</a>() and <a href="qvarlengtharray.html#end">end</a>().</p>
<!-- @@@constEnd -->
<!-- $$$count[overload1]$$$count -->
<h3 class="fn"><a name="count"></a><span class="type">int</span> QVarLengthArray::<span class="name">count</span> () const</h3>
<p>Same as <a href="qvarlengtharray.html#size">size</a>().</p>
<p><b>See also </b><a href="qvarlengtharray.html#isEmpty">isEmpty</a>() and <a href="qvarlengtharray.html#resize">resize</a>().</p>
<!-- @@@count -->
<!-- $$$data[overload1]$$$data -->
<h3 class="fn"><a name="data"></a><span class="type">T</span> * QVarLengthArray::<span class="name">data</span> ()</h3>
<p>Returns a pointer to the data stored in the array. The pointer can be used to access and modify the items in the array.</p>
<p>Example:</p>
<pre class="cpp"> <span class="type"><a href="qvarlengtharray.html">QVarLengthArray</a></span><span class="operator">&lt;</span><span class="type">int</span><span class="operator">&gt;</span> array(<span class="number">10</span>);
 <span class="type">int</span> <span class="operator">*</span>data <span class="operator">=</span> array<span class="operator">.</span>data();
 <span class="keyword">for</span> (<span class="type">int</span> i <span class="operator">=</span> <span class="number">0</span>; i <span class="operator">&lt;</span> <span class="number">10</span>; <span class="operator">+</span><span class="operator">+</span>i)
     data<span class="operator">[</span>i<span class="operator">]</span> <span class="operator">=</span> <span class="number">2</span> <span class="operator">*</span> i;</pre>
<p>The pointer remains valid as long as the array isn't reallocated.</p>
<p>This function is mostly useful to pass an array to a function that accepts a plain C++ array.</p>
<p><b>See also </b><a href="qvarlengtharray.html#constData">constData</a>() and <a href="qvarlengtharray.html#operator-5b-5d">operator[]</a>().</p>
<!-- @@@data -->
<!-- $$$data$$$data -->
<h3 class="fn"><a name="data-2"></a>const <span class="type">T</span> * QVarLengthArray::<span class="name">data</span> () const</h3>
<p>This is an overloaded function.</p>
<!-- @@@data -->
<!-- $$$end[overload1]$$$end -->
<h3 class="fn"><a name="end"></a><span class="type"><a href="qvarlengtharray.html#iterator-typedefx">iterator</a></span> QVarLengthArray::<span class="name">end</span> ()</h3>
<p>Returns an <a href="containers.html#stl-style-iterators">STL-style iterator</a> pointing to the imaginary item after the last item in the array.</p>
<p>This function was introduced in Qt 4.8.</p>
<p><b>See also </b><a href="qvarlengtharray.html#begin">begin</a>() and <a href="qvarlengtharray.html#constEnd">constEnd</a>().</p>
<!-- @@@end -->
<!-- $$$end$$$end -->
<h3 class="fn"><a name="end-2"></a><span class="type"><a href="qvarlengtharray.html#const_iterator-typedef">const_iterator</a></span> QVarLengthArray::<span class="name">end</span> () const</h3>
<p>This is an overloaded function.</p>
<p>This function was introduced in Qt 4.8.</p>
<!-- @@@end -->
<!-- $$$erase[overload1]$$$eraseiterator -->
<h3 class="fn"><a name="erase"></a><span class="type"><a href="qvarlengtharray.html#iterator-typedefx">iterator</a></span> QVarLengthArray::<span class="name">erase</span> ( <span class="type"><a href="qvarlengtharray.html#iterator-typedefx">iterator</a></span> <i>pos</i> )</h3>
<p>Removes the item pointed to by the iterator <i>pos</i> from the vector, and returns an iterator to the next item in the vector (which may be <a href="qvarlengtharray.html#end">end</a>()).</p>
<p>This function was introduced in Qt 4.8.</p>
<p><b>See also </b><a href="qvarlengtharray.html#insert">insert</a>() and <a href="qvarlengtharray.html#remove">remove</a>().</p>
<!-- @@@erase -->
<!-- $$$erase$$$eraseiteratoriterator -->
<h3 class="fn"><a name="erase-2"></a><span class="type"><a href="qvarlengtharray.html#iterator-typedefx">iterator</a></span> QVarLengthArray::<span class="name">erase</span> ( <span class="type"><a href="qvarlengtharray.html#iterator-typedefx">iterator</a></span> <i>begin</i>, <span class="type"><a href="qvarlengtharray.html#iterator-typedefx">iterator</a></span> <i>end</i> )</h3>
<p>This is an overloaded function.</p>
<p>Removes all the items from <i>begin</i> up to (but not including) <i>end</i>. Returns an iterator to the same item that <i>end</i> referred to before the call.</p>
<p>This function was introduced in Qt 4.8.</p>
<!-- @@@erase -->
<!-- $$$insert[overload1]$$$insertintconstT& -->
<h3 class="fn"><a name="insert"></a><span class="type">void</span> QVarLengthArray::<span class="name">insert</span> ( <span class="type">int</span> <i>i</i>, const <span class="type">T</span> &amp; <i>value</i> )</h3>
<p>Inserts <i>value</i> at index position <i>i</i> in the array. If <i>i</i> is 0, the value is prepended to the vector. If <i>i</i> is <a href="qvarlengtharray.html#size">size</a>(), the value is appended to the vector.</p>
<p>For large arrays, this operation can be slow (<a href="containers.html#linear-time">linear time</a>), because it requires moving all the items at indexes <i>i</i> and above by one position further in memory. If you want a container class that provides a fast insert() function, use <a href="qlinkedlist.html">QLinkedList</a> instead.</p>
<p>This function was introduced in Qt 4.8.</p>
<p><b>See also </b><a href="qvarlengtharray.html#remove">remove</a>().</p>
<!-- @@@insert -->
<!-- $$$insert$$$insertiteratorintconstT& -->
<h3 class="fn"><a name="insert-2"></a><span class="type"><a href="qvarlengtharray.html#iterator-typedefx">iterator</a></span> QVarLengthArray::<span class="name">insert</span> ( <span class="type"><a href="qvarlengtharray.html#iterator-typedefx">iterator</a></span> <i>before</i>, <span class="type">int</span> <i>count</i>, const <span class="type">T</span> &amp; <i>value</i> )</h3>
<p>Inserts <i>count</i> copies of <i>value</i> in front of the item pointed to by the iterator <i>before</i>. Returns an iterator pointing at the first of the inserted items.</p>
<p>This function was introduced in Qt 4.8.</p>
<!-- @@@insert -->
<!-- $$$insert$$$insertintintconstT& -->
<h3 class="fn"><a name="insert-3"></a><span class="type">void</span> QVarLengthArray::<span class="name">insert</span> ( <span class="type">int</span> <i>i</i>, <span class="type">int</span> <i>count</i>, const <span class="type">T</span> &amp; <i>value</i> )</h3>
<p>This is an overloaded function.</p>
<p>Inserts <i>count</i> copies of <i>value</i> at index position <i>i</i> in the vector.</p>
<p>This function was introduced in Qt 4.8.</p>
<!-- @@@insert -->
<!-- $$$insert$$$insertiteratorconstT& -->
<h3 class="fn"><a name="insert-4"></a><span class="type"><a href="qvarlengtharray.html#iterator-typedefx">iterator</a></span> QVarLengthArray::<span class="name">insert</span> ( <span class="type"><a href="qvarlengtharray.html#iterator-typedefx">iterator</a></span> <i>before</i>, const <span class="type">T</span> &amp; <i>value</i> )</h3>
<p>This is an overloaded function.</p>
<p>Inserts <i>value</i> in front of the item pointed to by the iterator <i>before</i>. Returns an iterator pointing at the inserted item.</p>
<p>This function was introduced in Qt 4.8.</p>
<!-- @@@insert -->
<!-- $$$isEmpty[overload1]$$$isEmpty -->
<h3 class="fn"><a name="isEmpty"></a><span class="type">bool</span> QVarLengthArray::<span class="name">isEmpty</span> () const</h3>
<p>Returns true if the array has size 0; otherwise returns false.</p>
<p><b>See also </b><a href="qvarlengtharray.html#size">size</a>() and <a href="qvarlengtharray.html#resize">resize</a>().</p>
<!-- @@@isEmpty -->
<!-- $$$prepend[overload1]$$$prependconstT& -->
<h3 class="fn"><a name="prepend"></a><span class="type">void</span> QVarLengthArray::<span class="name">prepend</span> ( const <span class="type">T</span> &amp; <i>value</i> )</h3>
<p>Inserts <i>value</i> at the beginning of the array.</p>
<p>This is the same as vector.insert(0, <i>value</i>).</p>
<p>For large arrays, this operation can be slow (<a href="containers.html#linear-time">linear time</a>), because it requires moving all the items in the vector by one position further in memory. If you want a container class that provides a fast prepend() function, use <a href="qlist.html">QList</a> or <a href="qlinkedlist.html">QLinkedList</a> instead.</p>
<p>This function was introduced in Qt 4.8.</p>
<p><b>See also </b><a href="qvarlengtharray.html#append">append</a>() and <a href="qvarlengtharray.html#insert">insert</a>().</p>
<!-- @@@prepend -->
<!-- $$$remove[overload1]$$$removeint -->
<h3 class="fn"><a name="remove"></a><span class="type">void</span> QVarLengthArray::<span class="name">remove</span> ( <span class="type">int</span> <i>i</i> )</h3>
<p>This is an overloaded function.</p>
<p>Removes the element at index position <i>i</i>.</p>
<p>This function was introduced in Qt 4.8.</p>
<p><b>See also </b><a href="qvarlengtharray.html#insert">insert</a>() and <a href="qvarlengtharray.html#replace">replace</a>().</p>
<!-- @@@remove -->
<!-- $$$remove$$$removeintint -->
<h3 class="fn"><a name="remove-2"></a><span class="type">void</span> QVarLengthArray::<span class="name">remove</span> ( <span class="type">int</span> <i>i</i>, <span class="type">int</span> <i>count</i> )</h3>
<p>This is an overloaded function.</p>
<p>Removes <i>count</i> elements from the middle of the array, starting at index position <i>i</i>.</p>
<p>This function was introduced in Qt 4.8.</p>
<p><b>See also </b><a href="qvarlengtharray.html#insert">insert</a>() and <a href="qvarlengtharray.html#replace">replace</a>().</p>
<!-- @@@remove -->
<!-- $$$removeLast[overload1]$$$removeLast -->
<h3 class="fn"><a name="removeLast"></a><span class="type">void</span> QVarLengthArray::<span class="name">removeLast</span> ()</h3>
<p>Decreases the size of the array by one. The allocated size is not changed.</p>
<p>This function was introduced in Qt 4.5.</p>
<p><b>See also </b><a href="qvarlengtharray.html#append">append</a>().</p>
<!-- @@@removeLast -->
<!-- $$$replace[overload1]$$$replaceintconstT& -->
<h3 class="fn"><a name="replace"></a><span class="type">void</span> QVarLengthArray::<span class="name">replace</span> ( <span class="type">int</span> <i>i</i>, const <span class="type">T</span> &amp; <i>value</i> )</h3>
<p>Replaces the item at index position <i>i</i> with <i>value</i>.</p>
<p><i>i</i> must be a valid index position in the array (i.e&#x2e;, 0 &lt;= <i>i</i> &lt; <a href="qvarlengtharray.html#size">size</a>()).</p>
<p>This function was introduced in Qt 4.8.</p>
<p><b>See also </b><a href="qvarlengtharray.html#operator-5b-5d">operator[]</a>() and <a href="qvarlengtharray.html#remove">remove</a>().</p>
<!-- @@@replace -->
<!-- $$$reserve[overload1]$$$reserveint -->
<h3 class="fn"><a name="reserve"></a><span class="type">void</span> QVarLengthArray::<span class="name">reserve</span> ( <span class="type">int</span> <i>size</i> )</h3>
<p>Attempts to allocate memory for at least <i>size</i> elements. If you know in advance how large the array can get, you can call this function and if you call <a href="qvarlengtharray.html#resize">resize</a>() often, you are likely to get better performance. If <i>size</i> is an underestimate, the worst that will happen is that the <a href="qvarlengtharray.html">QVarLengthArray</a> will be a bit slower.</p>
<p>The sole purpose of this function is to provide a means of fine tuning <a href="qvarlengtharray.html">QVarLengthArray</a>'s memory usage. In general, you will rarely ever need to call this function. If you want to change the size of the array, call <a href="qvarlengtharray.html#resize">resize</a>().</p>
<p><b>See also </b><a href="qvarlengtharray.html#capacity">capacity</a>().</p>
<!-- @@@reserve -->
<!-- $$$resize[overload1]$$$resizeint -->
<h3 class="fn"><a name="resize"></a><span class="type">void</span> QVarLengthArray::<span class="name">resize</span> ( <span class="type">int</span> <i>size</i> )</h3>
<p>Sets the size of the array to <i>size</i>. If <i>size</i> is greater than the current size, elements are added to the end. If <i>size</i> is less than the current size, elements are removed from the end.</p>
<p>If the value type is a primitive type (e.g&#x2e;, char, int, float) or a pointer type (e.g&#x2e;, <a href="qwidget.html">QWidget</a> *), new elements are not initialized. For other types, the elements are initialized with a <a href="containers.html#default-constructed-values">default-constructed value</a>.</p>
<p><b>See also </b><a href="qvarlengtharray.html#size">size</a>().</p>
<!-- @@@resize -->
<!-- $$$size[overload1]$$$size -->
<h3 class="fn"><a name="size"></a><span class="type">int</span> QVarLengthArray::<span class="name">size</span> () const</h3>
<p>Returns the number of elements in the array.</p>
<p><b>See also </b><a href="qvarlengtharray.html#isEmpty">isEmpty</a>() and <a href="qvarlengtharray.html#resize">resize</a>().</p>
<!-- @@@size -->
<!-- $$$value[overload1]$$$valueint -->
<h3 class="fn"><a name="value"></a><span class="type">T</span> QVarLengthArray::<span class="name">value</span> ( <span class="type">int</span> <i>i</i> ) const</h3>
<p>Returns the value at index position <i>i</i>.</p>
<p>If the index <i>i</i> is out of bounds, the function returns a <a href="containers.html#default-constructed-values">default-constructed value</a>. If you are certain that <i>i</i> is within bounds, you can use <a href="qvarlengtharray.html#at">at</a>() instead, which is slightly faster.</p>
<p><b>See also </b><a href="qvarlengtharray.html#at">at</a>() and <a href="qvarlengtharray.html#operator-5b-5d">operator[]</a>().</p>
<!-- @@@value -->
<!-- $$$value$$$valueintconstT& -->
<h3 class="fn"><a name="value-2"></a><span class="type">T</span> QVarLengthArray::<span class="name">value</span> ( <span class="type">int</span> <i>i</i>, const <span class="type">T</span> &amp; <i>defaultValue</i> ) const</h3>
<p>This is an overloaded function.</p>
<p>If the index <i>i</i> is out of bounds, the function returns <i>defaultValue</i>.</p>
<!-- @@@value -->
<!-- $$$operator+=[overload1]$$$operator+=constT& -->
<h3 class="fn"><a name="operator-2b-eq"></a><span class="type">QVarLengthArray</span>&lt;<span class="type">T</span>, <span class="type">Prealloc</span>&gt; &amp; QVarLengthArray::<span class="name">operator+=</span> ( const <span class="type">T</span> &amp; <i>value</i> )</h3>
<p>Appends <i>value</i> to the array and returns a reference to this vector.</p>
<p>This function was introduced in Qt 4.8.</p>
<p><b>See also </b><a href="qvarlengtharray.html#append">append</a>() and <a href="qvarlengtharray.html#operator-lt-lt">operator&lt;&lt;</a>().</p>
<!-- @@@operator+= -->
<!-- $$$operator<<[overload1]$$$operator<<constT& -->
<h3 class="fn"><a name="operator-lt-lt"></a><span class="type">QVarLengthArray</span>&lt;<span class="type">T</span>, <span class="type">Prealloc</span>&gt; &amp; QVarLengthArray::<span class="name">operator&lt;&lt;</span> ( const <span class="type">T</span> &amp; <i>value</i> )</h3>
<p>Appends <i>value</i> to the array and returns a reference to this vector.</p>
<p>This function was introduced in Qt 4.8.</p>
<p><b>See also </b><a href="qvarlengtharray.html#append">append</a>() and <a href="qvarlengtharray.html#operator-2b-eq">operator+=</a>().</p>
<!-- @@@operator<< -->
<!-- $$$operator=[overload1]$$$operator=constQVarLengthArray<T,Prealloc>& -->
<h3 class="fn"><a name="operator-eq"></a><span class="type">QVarLengthArray</span>&lt;<span class="type">T</span>, <span class="type">Prealloc</span>&gt; &amp; QVarLengthArray::<span class="name">operator=</span> ( const <span class="type">QVarLengthArray</span>&lt;<span class="type">T</span>, <span class="type">Prealloc</span>&gt; &amp; <i>other</i> )</h3>
<p>Assigns <i>other</i> to this array and returns a reference to this array.</p>
<!-- @@@operator= -->
<!-- $$$operator[][overload1]$$$operator[]int -->
<h3 class="fn"><a name="operator-5b-5d"></a><span class="type">T</span> &amp; QVarLengthArray::<span class="name">operator[]</span> ( <span class="type">int</span> <i>i</i> )</h3>
<p>Returns a reference to the item at index position <i>i</i>.</p>
<p><i>i</i> must be a valid index position in the array (i.e&#x2e;, 0 &lt;= <i>i</i> &lt; <a href="qvarlengtharray.html#size">size</a>()).</p>
<p><b>See also </b><a href="qvarlengtharray.html#data">data</a>() and <a href="qvarlengtharray.html#at">at</a>().</p>
<!-- @@@operator[] -->
<!-- $$$operator[]$$$operator[]int -->
<h3 class="fn"><a name="operator-5b-5d-2"></a>const <span class="type">T</span> &amp; QVarLengthArray::<span class="name">operator[]</span> ( <span class="type">int</span> <i>i</i> ) const</h3>
<p>This is an overloaded function.</p>
<!-- @@@operator[] -->
</div>
<div class="relnonmem">
<h2>Related Non-Members</h2>
<!-- $$$operator!=$$$operator!=constQVarLengthArray<T,Prealloc1>&constQVarLengthArray<T,Prealloc2>& -->
<h3 class="fn"><a name="operator-not-eq-32"></a><span class="type">bool</span> <span class="name">operator!=</span> ( const <span class="type">QVarLengthArray</span>&lt;<span class="type">T</span>, <span class="type">Prealloc1</span>&gt; &amp; <i>left</i>, const <span class="type">QVarLengthArray</span>&lt;<span class="type">T</span>, <span class="type">Prealloc2</span>&gt; &amp; <i>right</i> )</h3>
<p>Returns true if the two arrays, specified by <i>left</i> and <i>right</i>, are <i>not</i> equal.</p>
<p>Two arrays are considered equal if they contain the same values in the same order.</p>
<p>This function requires the value type to have an implementation of <tt>operator==()</tt>.</p>
<p>This function was introduced in Qt 4.8.</p>
<p><b>See also </b><a href="qvector3d.html#operator-eq-eq">operator==</a>().</p>
<!-- @@@operator!= -->
<!-- $$$operator==$$$operator==constQVarLengthArray<T,Prealloc1>&constQVarLengthArray<T,Prealloc2>& -->
<h3 class="fn"><a name="operator-eq-eq-34"></a><span class="type">bool</span> <span class="name">operator==</span> ( const <span class="type">QVarLengthArray</span>&lt;<span class="type">T</span>, <span class="type">Prealloc1</span>&gt; &amp; <i>left</i>, const <span class="type">QVarLengthArray</span>&lt;<span class="type">T</span>, <span class="type">Prealloc2</span>&gt; &amp; <i>right</i> )</h3>
<p>Returns true if the two arrays, specified by <i>left</i> and <i>right</i>, are equal.</p>
<p>Two arrays are considered equal if they contain the same values in the same order.</p>
<p>This function requires the value type to have an implementation of <tt>operator==()</tt>.</p>
<p>This function was introduced in Qt 4.8.</p>
<p><b>See also </b><a href="qvector3d.html#operator-not-eq">operator!=</a>().</p>
<!-- @@@operator== -->
</div>
      </div>
    </div>
    </div> 
    <div class="ft">
      <span></span>
    </div>
  </div> 
  <div class="footer">
    <p>
      <acronym title="Copyright">&copy;</acronym> 2015 The Qt Company Ltd.
      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>
      Qt and respective logos are trademarks of The Qt Company Ltd 
      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>