Sophie

Sophie

distrib > Mageia > 7 > i586 > by-pkgid > 1dd17e0d683ef79b4bb6872bbf359d7f > files > 4734

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" />
<!-- q3valuevector.qdoc -->
  <title>Qt 4.8: Q3ValueVector 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>Qt3SupportLight</li>
<li>Q3ValueVector</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="#details">Detailed Description</a></li>
</ul>
</div>
<h1 class="title">Q3ValueVector Class Reference</h1>
<!-- $$$Q3ValueVector-brief -->
<p>The Q3ValueVector class is a value-based template class that provides a dynamic array. <a href="#details">More...</a></p>
<!-- @@@Q3ValueVector -->
<pre class="cpp"> <span class="preprocessor">#include &lt;Q3ValueVector&gt;</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="qvector.html">QVector&lt;T&gt;</a>.</p>
<ul>
<li><a href="q3valuevector-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="q3valuevector.html#Q3ValueVector">Q3ValueVector</a></b> ()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="q3valuevector.html#Q3ValueVector-2">Q3ValueVector</a></b> ( const Q3ValueVector&lt;T&gt; &amp; <i>v</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="q3valuevector.html#Q3ValueVector-3">Q3ValueVector</a></b> ( QVector&lt;T&gt;::size_type <i>n</i>, const T &amp; <i>val</i> = T() )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="q3valuevector.html#Q3ValueVector-4">Q3ValueVector</a></b> ( const std::vector&lt;T&gt; &amp; <i>v</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> T &amp; </td><td class="memItemRight bottomAlign"><b><a href="q3valuevector.html#at">at</a></b> ( int <i>i</i>, bool * <i>ok</i> = 0 )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> const T &amp; </td><td class="memItemRight bottomAlign"><b><a href="q3valuevector.html#at-2">at</a></b> ( int <i>i</i>, bool * <i>ok</i> = 0 ) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="q3valuevector.html#resize">resize</a></b> ( int <i>n</i>, const T &amp; <i>val</i> = T() )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> Q3ValueVector&lt;T&gt; &amp; </td><td class="memItemRight bottomAlign"><b><a href="q3valuevector.html#operator-eq">operator=</a></b> ( const Q3ValueVector&lt;T&gt; &amp; <i>v</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> Q3ValueVector&lt;T&gt; &amp; </td><td class="memItemRight bottomAlign"><b><a href="q3valuevector.html#operator-eq-2">operator=</a></b> ( const std::vector&lt;T&gt; &amp; <i>v</i> )</td></tr>
</table>
<ul>
<li class="fn">65 public functions inherited from <a href="qvector.html#public-functions">QVector</a></li>
</ul>
<h3>Additional Inherited Members</h3>
<ul>
<li class="fn">2 static public members inherited from <a href="qvector.html#static-public-members">QVector</a></li>
</ul>
<a name="details"></a>
<!-- $$$Q3ValueVector-description -->
<div class="descr">
<h2>Detailed Description</h2>
<p>The Q3ValueVector class is a value-based template class that provides a dynamic array.</p>
<p>Q3ValueVector is a Qt implementation of an STL-like vector container. It can be used in your application if the standard <tt>vector</tt> is not available for your target platforms.</p>
<p>Q3ValueVector&lt;T&gt; defines a template instance to create a vector of values that all have the class T. Q3ValueVector does not store pointers to the members of the vector; it holds a copy of every member. Q3ValueVector is said to be value based; in contrast, <a href="q3ptrlist.html">Q3PtrList</a> and <a href="q3dict.html">Q3Dict</a> are pointer based.</p>
<p>Q3ValueVector contains and manages a collection of objects of type T and provides random access iterators that allow the contained objects to be addressed. Q3ValueVector owns the contained elements. For more relaxed ownership semantics, see <a href="q3ptrcollection.html">Q3PtrCollection</a> and friends, which are pointer-based containers.</p>
<p>Q3ValueVector provides good performance if you append or remove elements from the end of the vector. If you insert or remove elements from anywhere but the end, performance is very bad. The reason for this is that elements must to be copied into new positions.</p>
<p>Some classes cannot be used within a Q3ValueVector: for example, all classes derived from <a href="qobject.html">QObject</a> and thus all classes that implement widgets. Only values can be used in a Q3ValueVector. To qualify as a value the class must provide:</p>
<ul>
<li>a copy constructor;</li>
<li>an assignment operator;</li>
<li>a default constructor, i.e&#x2e;, a constructor that does not take any arguments.</li>
</ul>
<p>Note that C++ defaults to field-by-field assignment operators and copy constructors if no explicit version is supplied. In many cases this is sufficient.</p>
<p>Q3ValueVector uses an STL-like syntax to manipulate and address the objects it contains.</p>
<p>Example:</p>
<pre class="cpp"> <span class="preprocessor">#include &lt;qvaluevector.h&gt;</span>
 <span class="preprocessor">#include &lt;qstring.h&gt;</span>
 <span class="preprocessor">#include &lt;stdio.h&gt;</span>

 <span class="keyword">class</span> Employee
 {
 <span class="keyword">public</span>:
     Employee(): s(<span class="number">0</span>) {}
     Employee( <span class="keyword">const</span> <span class="type"><a href="qstring.html">QString</a></span><span class="operator">&amp;</span> name<span class="operator">,</span> <span class="type">int</span> salary )
         : n( name )<span class="operator">,</span> s( salary )
     { }

     <span class="type"><a href="qstring.html">QString</a></span> name()   <span class="keyword">const</span>              { <span class="keyword">return</span> n; }
     <span class="type">int</span> salary() <span class="keyword">const</span>          { <span class="keyword">return</span> s; }
     <span class="type">void</span>        setSalary( <span class="type">int</span> salary ) { s <span class="operator">=</span> salary; }
 <span class="keyword">private</span>:
     <span class="type"><a href="qstring.html">QString</a></span> n;
     <span class="type">int</span>     s;
 };

 <span class="type">int</span> main()
 {
     <span class="keyword">typedef</span> <span class="type">Q3ValueVector</span><span class="operator">&lt;</span>Employee<span class="operator">&gt;</span> EmployeeVector;
     EmployeeVector vec( <span class="number">3</span> );  <span class="comment">// vector of 3 Employees</span>

     vec<span class="operator">[</span><span class="number">0</span><span class="operator">]</span> <span class="operator">=</span> Employee( <span class="string">&quot;Bill&quot;</span><span class="operator">,</span> <span class="number">50000</span> );
     vec<span class="operator">[</span><span class="number">1</span><span class="operator">]</span> <span class="operator">=</span> Employee( <span class="string">&quot;Steve&quot;</span><span class="operator">,</span> <span class="number">80000</span> );
     vec<span class="operator">[</span><span class="number">2</span><span class="operator">]</span> <span class="operator">=</span> Employee( <span class="string">&quot;Ron&quot;</span><span class="operator">,</span> <span class="number">60000</span> );

     Employee joe( <span class="string">&quot;Joe&quot;</span><span class="operator">,</span> <span class="number">50000</span> );
     vec<span class="operator">.</span>push_back( joe );  <span class="comment">// vector expands to accommodate 4 Employees</span>
     joe<span class="operator">.</span>setSalary( <span class="number">70000</span> );

     EmployeeVector<span class="operator">::</span>iterator it;
     <span class="keyword">for</span>( it <span class="operator">=</span> vec<span class="operator">.</span>begin(); it <span class="operator">!</span><span class="operator">=</span> vec<span class="operator">.</span>end(); <span class="operator">+</span><span class="operator">+</span>it )
         printf( <span class="string">&quot;%s earns %d\n&quot;</span><span class="operator">,</span> (<span class="operator">*</span>it)<span class="operator">.</span>name()<span class="operator">.</span>latin1()<span class="operator">,</span> (<span class="operator">*</span>it)<span class="operator">.</span>salary() );

     <span class="keyword">return</span> <span class="number">0</span>;
 }</pre>
<p>Program output:</p>
<pre class="cpp"> Bill earns <span class="number">50000</span>
 Steve earns <span class="number">80000</span>
 Ron earns <span class="number">60000</span>
 Joe earns <span class="number">50000</span></pre>
<p>As you can see, the most recent change to Joe's salary did not affect the value in the vector because the vector created a copy of Joe's entry.</p>
<p>Many Qt functions return const value vectors; to iterate over these you should make a copy and iterate over the copy.</p>
<p>There are several ways to find items in the vector. The <a href="qvector.html#begin">begin</a>() and <a href="qvector.html#end">end</a>() functions return iterators to the beginning and end of the vector. The advantage of getting an iterator is that you can move forward or backward from this position by incrementing/decrementing the iterator. The iterator returned by <a href="qvector.html#end">end</a>() points to the element which is one past the last element in the container. The past-the-end iterator is still associated with the vector it belongs to, however it is <i>not</i> dereferenceable; operator*() will not return a well-defined value. If the vector is <a href="qvector.html#empty">empty</a>(), the iterator returned by <a href="qvector.html#begin">begin</a>() will equal the iterator returned by <a href="qvector.html#end">end</a>().</p>
<p>The fastest way to access an element of a vector is by using operator[]. This function provides random access and will return a reference to the element located at the specified index. Thus, you can access every element directly, in constant time, providing you know the location of the element. It is undefined to access an element that does not exist (your application will probably crash). For example:</p>
<pre class="cpp"> <span class="type">Q3ValueVector</span><span class="operator">&lt;</span><span class="type">int</span><span class="operator">&gt;</span> vec1;  <span class="comment">// an empty vector</span>
 vec1<span class="operator">[</span><span class="number">10</span><span class="operator">]</span> <span class="operator">=</span> <span class="number">4</span>;  <span class="comment">// WARNING: undefined, probably a crash</span>

 <span class="type">Q3ValueVector</span><span class="operator">&lt;</span><span class="type"><a href="qstring.html">QString</a></span><span class="operator">&gt;</span> vec2(<span class="number">25</span>); <span class="comment">// initialize with 25 elements</span>
 vec2<span class="operator">[</span><span class="number">10</span><span class="operator">]</span> <span class="operator">=</span> <span class="string">&quot;Dave&quot;</span>;  <span class="comment">// OK</span></pre>
<p>Whenever inserting, removing or referencing elements in a vector, always make sure you are referring to valid positions. For example:</p>
<pre class="cpp"> <span class="type">void</span> func( <span class="type">Q3ValueVector</span><span class="operator">&lt;</span><span class="type">int</span><span class="operator">&gt;</span><span class="operator">&amp;</span> vec )
 {
     <span class="keyword">if</span> ( vec<span class="operator">.</span>size() <span class="operator">&gt;</span> <span class="number">10</span> ) {
         vec<span class="operator">[</span><span class="number">9</span><span class="operator">]</span> <span class="operator">=</span> <span class="number">99</span>; <span class="comment">// OK</span>
     }
 };</pre>
<p>The iterators provided by vector are random access iterators, therefore you can use them with many generic algorithms, for example, algorithms provided by the STL.</p>
<p>It is safe to have multiple iterators on the vector at the same time. Since Q3ValueVector manages memory dynamically, all iterators can become invalid if a memory reallocation occurs. For example, if some member of the vector is removed, iterators that point to the removed element and to all following elements become invalidated. Inserting into the middle of the vector will invalidate all iterators. For convenience, the function <a href="qvector.html#back">back</a>() returns a reference to the last element in the vector, and <a href="qvector.html#front">front</a>() returns a reference to the first element. If the vector is <a href="qvector.html#empty">empty</a>(), both <a href="qvector.html#back">back</a>() and <a href="qvector.html#front">front</a>() have undefined behavior (your application will crash or do unpredictable things). Use <a href="qvector.html#back">back</a>() and <a href="qvector.html#front">front</a>() with caution, for example:</p>
<pre class="cpp"> <span class="type">Q3ValueVector</span><span class="operator">&lt;</span><span class="type">int</span><span class="operator">&gt;</span> vec( <span class="number">3</span> );
 vec<span class="operator">.</span><a href="qvector.html#push_back">push_back</a>( <span class="number">1</span> );
 vec<span class="operator">.</span><a href="qvector.html#push_back">push_back</a>( <span class="number">2</span> );
 vec<span class="operator">.</span><a href="qvector.html#push_back">push_back</a>( <span class="number">3</span> );
 <span class="operator">.</span><span class="operator">.</span><span class="operator">.</span>
 <span class="keyword">if</span> ( <span class="operator">!</span>vec<span class="operator">.</span>empty() ) {
     <span class="comment">// OK: modify the first element</span>
     <span class="type">int</span><span class="operator">&amp;</span> i <span class="operator">=</span> vec<span class="operator">.</span>front();
     i <span class="operator">=</span> <span class="number">18</span>;
 }
 <span class="operator">.</span><span class="operator">.</span><span class="operator">.</span>
 <span class="type">Q3ValueVector</span><span class="operator">&lt;</span><span class="type">double</span><span class="operator">&gt;</span> dvec;
 <span class="type">double</span> d <span class="operator">=</span> dvec<span class="operator">.</span><a href="qvector.html#back">back</a>(); <span class="comment">// undefined behavior</span></pre>
<p>Because Q3ValueVector manages memory dynamically, it is recommended that you contruct a vector with an initial size. Inserting and removing elements happens fastest when:</p>
<ul>
<li>Inserting or removing elements happens at the <a href="qvector.html#end">end</a>() of the vector;</li>
<li>The vector does not need to allocate additional memory.</li>
</ul>
<p>By creating a Q3ValueVector with a sufficiently large initial size, there will be less memory allocations. Do not use an initial size that is too big, since it will still take time to construct all the empty entries, and the extra space will be wasted if it is never used.</p>
<p>Because Q3ValueVector is value-based there is no need to be careful about deleting elements in the vector. The vector holds its own copies and will free them if the corresponding member or the vector itself is deleted. You can force the vector to free all of its items with <a href="qvector.html#clear">clear</a>().</p>
<p>Q3ValueVector is shared implicitly, which means it can be copied in constant time. If multiple Q3ValueVector instances share the same data and one needs to modify its contents, this modifying instance makes a copy and modifies its private copy; it thus does not affect the other instances. This is often called &quot;copy on write&quot;. If a Q3ValueVector is being used in a multi-threaded program, you must protect all access to the vector. See <a href="qmutex.html">QMutex</a>.</p>
<p>There are several ways to insert elements into the vector. The <a href="qvector.html#push_back">push_back</a>() function insert elements into the end of the vector, and is usually fastest. The <a href="qvector.html#insert">insert</a>() function can be used to add elements at specific positions within the vector.</p>
<p>Items can be also be removed from the vector in several ways. There are several variants of the <a href="qvector.html#erase">erase</a>() function which removes a specific element, or range of elements, from the vector.</p>
<p>Q3ValueVector stores its elements in contiguous memory. This means that you can use a Q3ValueVector in any situation that requires an array.</p>
</div>
<!-- @@@Q3ValueVector -->
<div class="func">
<h2>Member Function Documentation</h2>
<!-- $$$Q3ValueVector[overload1]$$$Q3ValueVector -->
<h3 class="fn"><a name="Q3ValueVector"></a>Q3ValueVector::<span class="name">Q3ValueVector</span> ()</h3>
<p>Constructs an empty vector without any elements. To create a vector which reserves an initial amount of space for elements, use <tt>Q3ValueVector(size_type n)</tt>.</p>
<!-- @@@Q3ValueVector -->
<!-- $$$Q3ValueVector$$$Q3ValueVectorconstQ3ValueVector<T>& -->
<h3 class="fn"><a name="Q3ValueVector-2"></a>Q3ValueVector::<span class="name">Q3ValueVector</span> ( const <span class="type">Q3ValueVector</span>&lt;<span class="type">T</span>&gt; &amp; <i>v</i> )</h3>
<p>Constructs a copy of <i>v</i>.</p>
<p>This operation costs O(1) time because <a href="q3valuevector.html" class="compat">Q3ValueVector</a> is implicitly shared.</p>
<p>The first modification to the vector does takes O(n) time, because the elements must be copied.</p>
<!-- @@@Q3ValueVector -->
<!-- $$$Q3ValueVector$$$Q3ValueVectorQVector<T>::size_typeconstT& -->
<h3 class="fn"><a name="Q3ValueVector-3"></a>Q3ValueVector::<span class="name">Q3ValueVector</span> ( <span class="type"><a href="qvector.html">QVector</a></span>&lt;<span class="type">T</span>&gt;<span class="type">::size_type</span> <i>n</i>, const <span class="type">T</span> &amp; <i>val</i> = T() )</h3>
<p>Constructs a vector with an initial size of <i>n</i> elements. Each element is initialized with the value of <i>val</i>.</p>
<!-- @@@Q3ValueVector -->
<!-- $$$Q3ValueVector$$$Q3ValueVectorconststd::vector<T>& -->
<h3 class="fn"><a name="Q3ValueVector-4"></a>Q3ValueVector::<span class="name">Q3ValueVector</span> ( const <span class="type">std::vector</span>&lt;<span class="type">T</span>&gt; &amp; <i>v</i> )</h3>
<p>This operation costs O(n) time because <i>v</i> is copied.</p>
<!-- @@@Q3ValueVector -->
<!-- $$$at[overload1]$$$atintbool* -->
<h3 class="fn"><a name="at"></a><span class="type">T</span> &amp; Q3ValueVector::<span class="name">at</span> ( <span class="type">int</span> <i>i</i>, <span class="type">bool</span> * <i>ok</i> = 0 )</h3>
<p>Returns a reference to the element with index <i>i</i>. If <i>ok</i> is non-null, and the index <i>i</i> is out of range, *<i>ok</i> is set to FALSE and the returned reference is undefined. If the index <i>i</i> is within the range of the vector, and <i>ok</i> is non-null, *<i>ok</i> is set to TRUE and the returned reference is well defined.</p>
<!-- @@@at -->
<!-- $$$at$$$atintbool* -->
<h3 class="fn"><a name="at-2"></a>const <span class="type">T</span> &amp; Q3ValueVector::<span class="name">at</span> ( <span class="type">int</span> <i>i</i>, <span class="type">bool</span> * <i>ok</i> = 0 ) const</h3>
<p>This is an overloaded function.</p>
<p>Returns a const reference to the element with index <i>i</i>. If <i>ok</i> is non-null, and the index <i>i</i> is out of range, *<i>ok</i> is set to FALSE and the returned reference is undefined. If the index <i>i</i> is within the range of the vector, and <i>ok</i> is non-null, *<i>ok</i> is set to TRUE and the returned reference is well defined.</p>
<!-- @@@at -->
<!-- $$$resize[overload1]$$$resizeintconstT& -->
<h3 class="fn"><a name="resize"></a><span class="type">void</span> Q3ValueVector::<span class="name">resize</span> ( <span class="type">int</span> <i>n</i>, const <span class="type">T</span> &amp; <i>val</i> = T() )</h3>
<p>Changes the size of the vector to <i>n</i>. If <i>n</i> is greater than the current <a href="qvector.html#size">size</a>(), elements are added to the end and initialized with the value of <i>val</i>. If <i>n</i> is less than <a href="qvector.html#size">size</a>(), elements are removed from the end. If <i>n</i> is equal to <a href="qvector.html#size">size</a>() nothing happens.</p>
<!-- @@@resize -->
<!-- $$$operator=[overload1]$$$operator=constQ3ValueVector<T>& -->
<h3 class="fn"><a name="operator-eq"></a><span class="type">Q3ValueVector</span>&lt;<span class="type">T</span>&gt; &amp; Q3ValueVector::<span class="name">operator=</span> ( const <span class="type">Q3ValueVector</span>&lt;<span class="type">T</span>&gt; &amp; <i>v</i> )</h3>
<p>Assigns <i>v</i> to this vector and returns a reference to this vector.</p>
<p>All iterators of the current vector become invalidated by this operation. The cost of such an assignment is O(1) since <a href="q3valuevector.html" class="compat">Q3ValueVector</a> is implicitly shared.</p>
<!-- @@@operator= -->
<!-- $$$operator=$$$operator=conststd::vector<T>& -->
<h3 class="fn"><a name="operator-eq-2"></a><span class="type">Q3ValueVector</span>&lt;<span class="type">T</span>&gt; &amp; Q3ValueVector::<span class="name">operator=</span> ( const <span class="type">std::vector</span>&lt;<span class="type">T</span>&gt; &amp; <i>v</i> )</h3>
<p>This is an overloaded function.</p>
<p>Assigns <i>v</i> to this vector and returns a reference to this vector.</p>
<p>All iterators of the current vector become invalidated by this operation. The cost of this assignment is O(n) since <i>v</i> is copied.</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>