Sophie

Sophie

distrib > Mandriva > 2011.0 > i586 > by-pkgid > a16d689bc65aac5d987d5129109e6de5 > files > 915

irrlicht-doc-1.7.2-1.i586.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Irrlicht Engine: irrArray.h Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<table class="irrlicht" >
  <tr valign="middle"> 
    <td><font size="2"><a class="qindex" href="index.html"><font color="#FFFFFF">Home</font></a> 
      | <a class="qindex" href="namespaces.html"><font color="#FFFFFF">Namespaces</font></a> 
      | <a class="qindex" href="hierarchy.html"><font color="#FFFFFF">Hierarchy</font></a> 
      | <a class="qindex" href="classes.html"><font color="#FFFFFF">Alphabetical 
      List</font></a> | <a class="qindex" href="annotated.html"><font color="#FFFFFF"> 
      Class list</font></a> | <a class="qindex" href="files.html"><font color="#FFFFFF">Files</font></a> 
      | <a class="qindex" href="namespacemembers.html"><font color="#FFFFFF"> 
      Namespace&nbsp;Members</font></a> | <a class="qindex" href="functions.html"><font color="#FFFFFF">Class 
      members</font></a> | <a class="qindex" href="globals.html"><font color="#FFFFFF">File 
      members</font></a> | <a class="qindex" href="pages.html"><font color="#FFFFFF">Tutorials</font></a></font> </td>
  </tr>
</table>
<!-- Generated by Doxygen 1.6.2 -->
<h1>irrArray.h</h1><a href="irr_array_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">// Copyright (C) 2002-2010 Nikolaus Gebhardt</span>
<a name="l00002"></a>00002 <span class="comment">// This file is part of the &quot;Irrlicht Engine&quot; and the &quot;irrXML&quot; project.</span>
<a name="l00003"></a>00003 <span class="comment">// For conditions of distribution and use, see copyright notice in irrlicht.h and irrXML.h</span>
<a name="l00004"></a>00004 
<a name="l00005"></a>00005 <span class="preprocessor">#ifndef __IRR_ARRAY_H_INCLUDED__</span>
<a name="l00006"></a>00006 <span class="preprocessor"></span><span class="preprocessor">#define __IRR_ARRAY_H_INCLUDED__</span>
<a name="l00007"></a>00007 <span class="preprocessor"></span>
<a name="l00008"></a>00008 <span class="preprocessor">#include &quot;<a class="code" href="irr_types_8h.html">irrTypes.h</a>&quot;</span>
<a name="l00009"></a>00009 <span class="preprocessor">#include &quot;<a class="code" href="heapsort_8h.html">heapsort.h</a>&quot;</span>
<a name="l00010"></a>00010 <span class="preprocessor">#include &quot;<a class="code" href="irr_allocator_8h.html">irrAllocator.h</a>&quot;</span>
<a name="l00011"></a>00011 <span class="preprocessor">#include &quot;<a class="code" href="irr_math_8h.html">irrMath.h</a>&quot;</span>
<a name="l00012"></a>00012 
<a name="l00013"></a>00013 <span class="keyword">namespace </span>irr
<a name="l00014"></a>00014 {
<a name="l00015"></a>00015 <span class="keyword">namespace </span>core
<a name="l00016"></a>00016 {
<a name="l00017"></a>00017 
<a name="l00019"></a>00019 
<a name="l00021"></a>00021 <span class="keyword">template</span> &lt;<span class="keyword">class</span> T, <span class="keyword">typename</span> TAlloc = irrAllocator&lt;T&gt; &gt;
<a name="l00022"></a><a class="code" href="classirr_1_1core_1_1array.html">00022</a> <span class="keyword">class </span><a class="code" href="classirr_1_1core_1_1array.html" title="Self reallocating template array (like stl vector) with additional features.">array</a>
<a name="l00023"></a>00023 {
<a name="l00024"></a>00024 
<a name="l00025"></a>00025 <span class="keyword">public</span>:
<a name="l00026"></a>00026 
<a name="l00028"></a><a class="code" href="classirr_1_1core_1_1array.html#a5e0dd817352068af92448a08716f1252">00028</a>         <a class="code" href="classirr_1_1core_1_1array.html#a5e0dd817352068af92448a08716f1252" title="Default constructor for empty array.">array</a>()
<a name="l00029"></a>00029                 : data(0), allocated(0), used(0),
<a name="l00030"></a>00030                         strategy(<a class="code" href="namespaceirr_1_1core.html#aa2e91971d5e6e84de235bfabe3c7adbaa1fa5aed132891361601560ed3e067fe8">ALLOC_STRATEGY_DOUBLE</a>), free_when_destroyed(true), is_sorted(true)
<a name="l00031"></a>00031         {
<a name="l00032"></a>00032         }
<a name="l00033"></a>00033 
<a name="l00034"></a>00034 
<a name="l00036"></a>00036 
<a name="l00037"></a><a class="code" href="classirr_1_1core_1_1array.html#ab58c4b2c09693190b43ee16e99722b43">00037</a>         <a class="code" href="classirr_1_1core_1_1array.html#a5e0dd817352068af92448a08716f1252" title="Default constructor for empty array.">array</a>(<a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> start_count)
<a name="l00038"></a>00038       : data(0), allocated(0), used(0),
<a name="l00039"></a>00039         strategy(<a class="code" href="namespaceirr_1_1core.html#aa2e91971d5e6e84de235bfabe3c7adbaa1fa5aed132891361601560ed3e067fe8">ALLOC_STRATEGY_DOUBLE</a>), free_when_destroyed(true), is_sorted(true)
<a name="l00040"></a>00040         {
<a name="l00041"></a>00041                 <a class="code" href="classirr_1_1core_1_1array.html#a84e5d8a76ddfeb408168e4beb0d2d5d7" title="Reallocates the array, make it bigger or smaller.">reallocate</a>(start_count);
<a name="l00042"></a>00042         }
<a name="l00043"></a>00043 
<a name="l00044"></a>00044 
<a name="l00046"></a><a class="code" href="classirr_1_1core_1_1array.html#a4e584fd375dd5f994b6bd7afd7f7a60c">00046</a>         <a class="code" href="classirr_1_1core_1_1array.html#a5e0dd817352068af92448a08716f1252" title="Default constructor for empty array.">array</a>(<span class="keyword">const</span> <a class="code" href="classirr_1_1core_1_1array.html" title="Self reallocating template array (like stl vector) with additional features.">array&lt;T, TAlloc&gt;</a>&amp; other) : data(0)
<a name="l00047"></a>00047         {
<a name="l00048"></a>00048                 *<span class="keyword">this</span> = other;
<a name="l00049"></a>00049         }
<a name="l00050"></a>00050 
<a name="l00051"></a>00051 
<a name="l00053"></a>00053 
<a name="l00055"></a><a class="code" href="classirr_1_1core_1_1array.html#aac1853f45d4c18feaacac9859efe9836">00055</a>         <a class="code" href="classirr_1_1core_1_1array.html#aac1853f45d4c18feaacac9859efe9836" title="Destructor.">~array</a>()
<a name="l00056"></a>00056         {
<a name="l00057"></a>00057                 <a class="code" href="classirr_1_1core_1_1array.html#a236e08ca44ddf3c2b47b726f90db8d39" title="Clears the array and deletes all allocated memory.">clear</a>();
<a name="l00058"></a>00058         }
<a name="l00059"></a>00059 
<a name="l00060"></a>00060 
<a name="l00062"></a>00062 
<a name="l00063"></a><a class="code" href="classirr_1_1core_1_1array.html#a84e5d8a76ddfeb408168e4beb0d2d5d7">00063</a>         <span class="keywordtype">void</span> <a class="code" href="classirr_1_1core_1_1array.html#a84e5d8a76ddfeb408168e4beb0d2d5d7" title="Reallocates the array, make it bigger or smaller.">reallocate</a>(<a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> new_size)
<a name="l00064"></a>00064         {
<a name="l00065"></a>00065                 T* old_data = data;
<a name="l00066"></a>00066 
<a name="l00067"></a>00067                 data = allocator.allocate(new_size); <span class="comment">//new T[new_size];</span>
<a name="l00068"></a>00068                 allocated = new_size;
<a name="l00069"></a>00069 
<a name="l00070"></a>00070                 <span class="comment">// copy old data</span>
<a name="l00071"></a>00071                 <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> end = used &lt; new_size ? used : new_size;
<a name="l00072"></a>00072 
<a name="l00073"></a>00073                 <span class="keywordflow">for</span> (<a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> i=0; i&lt;end; ++i)
<a name="l00074"></a>00074                 {
<a name="l00075"></a>00075                         <span class="comment">// data[i] = old_data[i];</span>
<a name="l00076"></a>00076                         allocator.construct(&amp;data[i], old_data[i]);
<a name="l00077"></a>00077                 }
<a name="l00078"></a>00078 
<a name="l00079"></a>00079                 <span class="comment">// destruct old data</span>
<a name="l00080"></a>00080                 <span class="keywordflow">for</span> (<a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> j=0; j&lt;used; ++j)
<a name="l00081"></a>00081                         allocator.destruct(&amp;old_data[j]);
<a name="l00082"></a>00082 
<a name="l00083"></a>00083                 <span class="keywordflow">if</span> (allocated &lt; used)
<a name="l00084"></a>00084                         used = allocated;
<a name="l00085"></a>00085 
<a name="l00086"></a>00086                 allocator.deallocate(old_data); <span class="comment">//delete [] old_data;</span>
<a name="l00087"></a>00087         }
<a name="l00088"></a>00088 
<a name="l00089"></a>00089 
<a name="l00091"></a>00091 
<a name="l00094"></a><a class="code" href="classirr_1_1core_1_1array.html#a7aef3e5dbf91f8d1e8f365039e2497ae">00094</a>         <span class="keywordtype">void</span> <a class="code" href="classirr_1_1core_1_1array.html#a7aef3e5dbf91f8d1e8f365039e2497ae" title="set a new allocation strategy">setAllocStrategy</a> ( <a class="code" href="namespaceirr_1_1core.html#aa2e91971d5e6e84de235bfabe3c7adba" title="defines an allocation strategy">eAllocStrategy</a> newStrategy = <a class="code" href="namespaceirr_1_1core.html#aa2e91971d5e6e84de235bfabe3c7adbaa1fa5aed132891361601560ed3e067fe8">ALLOC_STRATEGY_DOUBLE</a> )
<a name="l00095"></a>00095         {
<a name="l00096"></a>00096                 strategy = newStrategy;
<a name="l00097"></a>00097         }
<a name="l00098"></a>00098 
<a name="l00099"></a>00099 
<a name="l00101"></a>00101 
<a name="l00103"></a><a class="code" href="classirr_1_1core_1_1array.html#ad2c9dff8592b95c25c59f5383fc633fe">00103</a>         <span class="keywordtype">void</span> <a class="code" href="classirr_1_1core_1_1array.html#ad2c9dff8592b95c25c59f5383fc633fe" title="Adds an element at back of array.">push_back</a>(<span class="keyword">const</span> T&amp; element)
<a name="l00104"></a>00104         {
<a name="l00105"></a>00105                 <a class="code" href="classirr_1_1core_1_1array.html#a3b0f73c95dd449a4de576c6b1943566c" title="Insert item into array at specified position.">insert</a>(element, used);
<a name="l00106"></a>00106         }
<a name="l00107"></a>00107 
<a name="l00108"></a>00108 
<a name="l00110"></a>00110 
<a name="l00114"></a><a class="code" href="classirr_1_1core_1_1array.html#a31b686ce4b1ebae930f22bc40d30efbd">00114</a>         <span class="keywordtype">void</span> <a class="code" href="classirr_1_1core_1_1array.html#a31b686ce4b1ebae930f22bc40d30efbd" title="Adds an element at the front of the array.">push_front</a>(<span class="keyword">const</span> T&amp; element)
<a name="l00115"></a>00115         {
<a name="l00116"></a>00116                 <a class="code" href="classirr_1_1core_1_1array.html#a3b0f73c95dd449a4de576c6b1943566c" title="Insert item into array at specified position.">insert</a>(element);
<a name="l00117"></a>00117         }
<a name="l00118"></a>00118 
<a name="l00119"></a>00119 
<a name="l00121"></a>00121 
<a name="l00126"></a><a class="code" href="classirr_1_1core_1_1array.html#a3b0f73c95dd449a4de576c6b1943566c">00126</a>         <span class="keywordtype">void</span> <a class="code" href="classirr_1_1core_1_1array.html#a3b0f73c95dd449a4de576c6b1943566c" title="Insert item into array at specified position.">insert</a>(<span class="keyword">const</span> T&amp; element, <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> index=0)
<a name="l00127"></a>00127         {
<a name="l00128"></a>00128                 <a class="code" href="irr_types_8h.html#a12f3b5fd18ca108f90c5c74db602267e" title="define a break macro for debugging.">_IRR_DEBUG_BREAK_IF</a>(index&gt;used) <span class="comment">// access violation</span>
<a name="l00129"></a>00129 
<a name="l00130"></a>00130                 <span class="keywordflow">if</span> (used + 1 &gt; allocated)
<a name="l00131"></a>00131                 {
<a name="l00132"></a>00132                         <span class="comment">// this doesn&#39;t work if the element is in the same</span>
<a name="l00133"></a>00133                         <span class="comment">// array. So we&#39;ll copy the element first to be sure</span>
<a name="l00134"></a>00134                         <span class="comment">// we&#39;ll get no data corruption</span>
<a name="l00135"></a>00135                         <span class="keyword">const</span> T e(element);
<a name="l00136"></a>00136 
<a name="l00137"></a>00137                         <span class="comment">// increase data block</span>
<a name="l00138"></a>00138                         <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> newAlloc;
<a name="l00139"></a>00139                         <span class="keywordflow">switch</span> ( strategy )
<a name="l00140"></a>00140                         {
<a name="l00141"></a>00141                                 <span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1core.html#aa2e91971d5e6e84de235bfabe3c7adbaa1fa5aed132891361601560ed3e067fe8">ALLOC_STRATEGY_DOUBLE</a>:
<a name="l00142"></a>00142                                         newAlloc = used + 1 + (allocated &lt; 500 ?
<a name="l00143"></a>00143                                                         (allocated &lt; 5 ? 5 : used) : used &gt;&gt; 2);
<a name="l00144"></a>00144                                         <span class="keywordflow">break</span>;
<a name="l00145"></a>00145                                 <span class="keywordflow">default</span>:
<a name="l00146"></a>00146                                 <span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1core.html#aa2e91971d5e6e84de235bfabe3c7adbaabfc6be96075564e1e0d92477e657f746">ALLOC_STRATEGY_SAFE</a>:
<a name="l00147"></a>00147                                         newAlloc = used + 1;
<a name="l00148"></a>00148                                         <span class="keywordflow">break</span>;
<a name="l00149"></a>00149                         }
<a name="l00150"></a>00150                         <a class="code" href="classirr_1_1core_1_1array.html#a84e5d8a76ddfeb408168e4beb0d2d5d7" title="Reallocates the array, make it bigger or smaller.">reallocate</a>( newAlloc);
<a name="l00151"></a>00151 
<a name="l00152"></a>00152                         <span class="comment">// move array content and construct new element</span>
<a name="l00153"></a>00153                         <span class="comment">// first move end one up</span>
<a name="l00154"></a>00154                         <span class="keywordflow">for</span> (<a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> i=used; i&gt;index; --i)
<a name="l00155"></a>00155                         {
<a name="l00156"></a>00156                                 <span class="keywordflow">if</span> (i&lt;used)
<a name="l00157"></a>00157                                         allocator.destruct(&amp;data[i]);
<a name="l00158"></a>00158                                 allocator.construct(&amp;data[i], data[i-1]); <span class="comment">// data[i] = data[i-1];</span>
<a name="l00159"></a>00159                         }
<a name="l00160"></a>00160                         <span class="comment">// then add new element</span>
<a name="l00161"></a>00161                         <span class="keywordflow">if</span> (used &gt; index)
<a name="l00162"></a>00162                                 allocator.destruct(&amp;data[index]);
<a name="l00163"></a>00163                         allocator.construct(&amp;data[index], e); <span class="comment">// data[index] = e;</span>
<a name="l00164"></a>00164                 }
<a name="l00165"></a>00165                 <span class="keywordflow">else</span>
<a name="l00166"></a>00166                 {
<a name="l00167"></a>00167                         <span class="comment">// element inserted not at end</span>
<a name="l00168"></a>00168                         <span class="keywordflow">if</span> ( used &gt; index )
<a name="l00169"></a>00169                         {
<a name="l00170"></a>00170                                 <span class="comment">// create one new element at the end</span>
<a name="l00171"></a>00171                                 allocator.construct(&amp;data[used], data[used-1]);
<a name="l00172"></a>00172 
<a name="l00173"></a>00173                                 <span class="comment">// move the rest of the array content</span>
<a name="l00174"></a>00174                                 <span class="keywordflow">for</span> (<a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> i=used-1; i&gt;index; --i)
<a name="l00175"></a>00175                                 {
<a name="l00176"></a>00176                                         data[i] = data[i-1];
<a name="l00177"></a>00177                                 }
<a name="l00178"></a>00178                                 <span class="comment">// insert the new element</span>
<a name="l00179"></a>00179                                 data[index] = element;
<a name="l00180"></a>00180                         }
<a name="l00181"></a>00181                         <span class="keywordflow">else</span>
<a name="l00182"></a>00182                         {
<a name="l00183"></a>00183                                 <span class="comment">// insert the new element to the end</span>
<a name="l00184"></a>00184                                 allocator.construct(&amp;data[index], element);
<a name="l00185"></a>00185                         }
<a name="l00186"></a>00186                 }
<a name="l00187"></a>00187                 <span class="comment">// set to false as we don&#39;t know if we have the comparison operators</span>
<a name="l00188"></a>00188                 is_sorted = <span class="keyword">false</span>;
<a name="l00189"></a>00189                 ++used;
<a name="l00190"></a>00190         }
<a name="l00191"></a>00191 
<a name="l00192"></a>00192 
<a name="l00194"></a><a class="code" href="classirr_1_1core_1_1array.html#a236e08ca44ddf3c2b47b726f90db8d39">00194</a>         <span class="keywordtype">void</span> <a class="code" href="classirr_1_1core_1_1array.html#a236e08ca44ddf3c2b47b726f90db8d39" title="Clears the array and deletes all allocated memory.">clear</a>()
<a name="l00195"></a>00195         {
<a name="l00196"></a>00196                 <span class="keywordflow">if</span> (free_when_destroyed)
<a name="l00197"></a>00197                 {
<a name="l00198"></a>00198                         <span class="keywordflow">for</span> (<a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> i=0; i&lt;used; ++i)
<a name="l00199"></a>00199                                 allocator.destruct(&amp;data[i]);
<a name="l00200"></a>00200 
<a name="l00201"></a>00201                         allocator.deallocate(data); <span class="comment">// delete [] data;</span>
<a name="l00202"></a>00202                 }
<a name="l00203"></a>00203                 data = 0;
<a name="l00204"></a>00204                 used = 0;
<a name="l00205"></a>00205                 allocated = 0;
<a name="l00206"></a>00206                 is_sorted = <span class="keyword">true</span>;
<a name="l00207"></a>00207         }
<a name="l00208"></a>00208 
<a name="l00209"></a>00209 
<a name="l00211"></a>00211 
<a name="l00219"></a><a class="code" href="classirr_1_1core_1_1array.html#a75df5c46b08225d1ebe3c1381d85d9ff">00219</a>         <span class="keywordtype">void</span> <a class="code" href="classirr_1_1core_1_1array.html#a75df5c46b08225d1ebe3c1381d85d9ff" title="Sets pointer to new array, using this as new workspace.">set_pointer</a>(T* newPointer, <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> <a class="code" href="classirr_1_1core_1_1array.html#abc592bab637d54799b6c86d6d0e8adf8" title="Get number of occupied elements of the array.">size</a>, <span class="keywordtype">bool</span> _is_sorted=<span class="keyword">false</span>, <span class="keywordtype">bool</span> _free_when_destroyed=<span class="keyword">true</span>)
<a name="l00220"></a>00220         {
<a name="l00221"></a>00221                 <a class="code" href="classirr_1_1core_1_1array.html#a236e08ca44ddf3c2b47b726f90db8d39" title="Clears the array and deletes all allocated memory.">clear</a>();
<a name="l00222"></a>00222                 data = newPointer;
<a name="l00223"></a>00223                 allocated = size;
<a name="l00224"></a>00224                 used = size;
<a name="l00225"></a>00225                 is_sorted = _is_sorted;
<a name="l00226"></a>00226                 free_when_destroyed=_free_when_destroyed;
<a name="l00227"></a>00227         }
<a name="l00228"></a>00228 
<a name="l00229"></a>00229 
<a name="l00231"></a>00231 
<a name="l00238"></a><a class="code" href="classirr_1_1core_1_1array.html#afddd43e25d3ad6b1a3d75ceab13e6c56">00238</a>         <span class="keywordtype">void</span> <a class="code" href="classirr_1_1core_1_1array.html#afddd43e25d3ad6b1a3d75ceab13e6c56" title="Sets if the array should delete the memory it uses upon destruction.">set_free_when_destroyed</a>(<span class="keywordtype">bool</span> f)
<a name="l00239"></a>00239         {
<a name="l00240"></a>00240                 free_when_destroyed = f;
<a name="l00241"></a>00241         }
<a name="l00242"></a>00242 
<a name="l00243"></a>00243 
<a name="l00245"></a>00245 
<a name="l00248"></a><a class="code" href="classirr_1_1core_1_1array.html#a64d70ab89f03e2ec4deae3b6c0161305">00248</a>         <span class="keywordtype">void</span> <a class="code" href="classirr_1_1core_1_1array.html#a64d70ab89f03e2ec4deae3b6c0161305" title="Sets the size of the array and allocates new elements if necessary.">set_used</a>(<a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> usedNow)
<a name="l00249"></a>00249         {
<a name="l00250"></a>00250                 <span class="keywordflow">if</span> (allocated &lt; usedNow)
<a name="l00251"></a>00251                         <a class="code" href="classirr_1_1core_1_1array.html#a84e5d8a76ddfeb408168e4beb0d2d5d7" title="Reallocates the array, make it bigger or smaller.">reallocate</a>(usedNow);
<a name="l00252"></a>00252 
<a name="l00253"></a>00253                 used = usedNow;
<a name="l00254"></a>00254         }
<a name="l00255"></a>00255 
<a name="l00256"></a>00256 
<a name="l00258"></a><a class="code" href="classirr_1_1core_1_1array.html#a51c964d180507ebdef872d93886c23b2">00258</a>         <span class="keyword">const</span> <a class="code" href="classirr_1_1core_1_1array.html" title="Self reallocating template array (like stl vector) with additional features.">array&lt;T, TAlloc&gt;</a>&amp; <a class="code" href="classirr_1_1core_1_1array.html#a51c964d180507ebdef872d93886c23b2" title="Assignment operator.">operator=</a>(<span class="keyword">const</span> <a class="code" href="classirr_1_1core_1_1array.html" title="Self reallocating template array (like stl vector) with additional features.">array&lt;T, TAlloc&gt;</a>&amp; other)
<a name="l00259"></a>00259         {
<a name="l00260"></a>00260                 <span class="keywordflow">if</span> (<span class="keyword">this</span> == &amp;other)
<a name="l00261"></a>00261                         <span class="keywordflow">return</span> *<span class="keyword">this</span>;
<a name="l00262"></a>00262                 strategy = other.strategy;
<a name="l00263"></a>00263 
<a name="l00264"></a>00264                 <span class="keywordflow">if</span> (data)
<a name="l00265"></a>00265                         <a class="code" href="classirr_1_1core_1_1array.html#a236e08ca44ddf3c2b47b726f90db8d39" title="Clears the array and deletes all allocated memory.">clear</a>();
<a name="l00266"></a>00266 
<a name="l00267"></a>00267                 <span class="comment">//if (allocated &lt; other.allocated)</span>
<a name="l00268"></a>00268                 <span class="keywordflow">if</span> (other.allocated == 0)
<a name="l00269"></a>00269                         data = 0;
<a name="l00270"></a>00270                 <span class="keywordflow">else</span>
<a name="l00271"></a>00271                         data = allocator.allocate(other.allocated); <span class="comment">// new T[other.allocated];</span>
<a name="l00272"></a>00272 
<a name="l00273"></a>00273                 used = other.used;
<a name="l00274"></a>00274                 free_when_destroyed = <span class="keyword">true</span>;
<a name="l00275"></a>00275                 is_sorted = other.is_sorted;
<a name="l00276"></a>00276                 allocated = other.allocated;
<a name="l00277"></a>00277 
<a name="l00278"></a>00278                 <span class="keywordflow">for</span> (<a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> i=0; i&lt;other.used; ++i)
<a name="l00279"></a>00279                         allocator.construct(&amp;data[i], other.data[i]); <span class="comment">// data[i] = other.data[i];</span>
<a name="l00280"></a>00280 
<a name="l00281"></a>00281                 <span class="keywordflow">return</span> *<span class="keyword">this</span>;
<a name="l00282"></a>00282         }
<a name="l00283"></a>00283 
<a name="l00284"></a>00284 
<a name="l00286"></a><a class="code" href="classirr_1_1core_1_1array.html#a718e705f3e3561c49ceee75afe0c3251">00286</a>         <span class="keywordtype">bool</span> <a class="code" href="classirr_1_1core_1_1array.html#a718e705f3e3561c49ceee75afe0c3251" title="Equality operator.">operator == </a>(<span class="keyword">const</span> <a class="code" href="classirr_1_1core_1_1array.html" title="Self reallocating template array (like stl vector) with additional features.">array&lt;T, TAlloc&gt;</a>&amp; other)<span class="keyword"> const</span>
<a name="l00287"></a>00287 <span class="keyword">        </span>{
<a name="l00288"></a>00288                 <span class="keywordflow">if</span> (used != other.used)
<a name="l00289"></a>00289                         <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00290"></a>00290 
<a name="l00291"></a>00291                 <span class="keywordflow">for</span> (<a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> i=0; i&lt;other.used; ++i)
<a name="l00292"></a>00292                         <span class="keywordflow">if</span> (data[i] != other[i])
<a name="l00293"></a>00293                                 <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00294"></a>00294                 <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00295"></a>00295         }
<a name="l00296"></a>00296 
<a name="l00297"></a>00297 
<a name="l00299"></a><a class="code" href="classirr_1_1core_1_1array.html#a20f435e8fabd821b66ef34227c1fceae">00299</a>         <span class="keywordtype">bool</span> <a class="code" href="classirr_1_1core_1_1array.html#a20f435e8fabd821b66ef34227c1fceae" title="Inequality operator.">operator != </a>(<span class="keyword">const</span> <a class="code" href="classirr_1_1core_1_1array.html" title="Self reallocating template array (like stl vector) with additional features.">array&lt;T, TAlloc&gt;</a>&amp; other)<span class="keyword"> const</span>
<a name="l00300"></a>00300 <span class="keyword">        </span>{
<a name="l00301"></a>00301                 <span class="keywordflow">return</span> !(*<span class="keyword">this</span>==other);
<a name="l00302"></a>00302         }
<a name="l00303"></a>00303 
<a name="l00304"></a>00304 
<a name="l00306"></a><a class="code" href="classirr_1_1core_1_1array.html#a1e09dc5cc93e88fd3a37cad011b3b531">00306</a>         T&amp; <a class="code" href="classirr_1_1core_1_1array.html#a1e09dc5cc93e88fd3a37cad011b3b531" title="Direct access operator.">operator []</a>(<a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> index)
<a name="l00307"></a>00307         {
<a name="l00308"></a>00308                 <a class="code" href="irr_types_8h.html#a12f3b5fd18ca108f90c5c74db602267e" title="define a break macro for debugging.">_IRR_DEBUG_BREAK_IF</a>(index&gt;=used) <span class="comment">// access violation</span>
<a name="l00309"></a>00309 
<a name="l00310"></a>00310                 <span class="keywordflow">return</span> data[index];
<a name="l00311"></a>00311         }
<a name="l00312"></a>00312 
<a name="l00313"></a>00313 
<a name="l00315"></a><a class="code" href="classirr_1_1core_1_1array.html#a432981694ff74f416764bfbf71c76b4c">00315</a>         <span class="keyword">const</span> T&amp; <a class="code" href="classirr_1_1core_1_1array.html#a1e09dc5cc93e88fd3a37cad011b3b531" title="Direct access operator.">operator []</a>(<a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> index)<span class="keyword"> const</span>
<a name="l00316"></a>00316 <span class="keyword">        </span>{
<a name="l00317"></a>00317                 <a class="code" href="irr_types_8h.html#a12f3b5fd18ca108f90c5c74db602267e" title="define a break macro for debugging.">_IRR_DEBUG_BREAK_IF</a>(index&gt;=used) <span class="comment">// access violation</span>
<a name="l00318"></a>00318 
<a name="l00319"></a>00319                 <span class="keywordflow">return</span> data[index];
<a name="l00320"></a>00320         }
<a name="l00321"></a>00321 
<a name="l00322"></a>00322 
<a name="l00324"></a><a class="code" href="classirr_1_1core_1_1array.html#ad87dc5db8bf6ec1033c945a0d3724e09">00324</a>         T&amp; <a class="code" href="classirr_1_1core_1_1array.html#ad87dc5db8bf6ec1033c945a0d3724e09" title="Gets last element.">getLast</a>()
<a name="l00325"></a>00325         {
<a name="l00326"></a>00326                 <a class="code" href="irr_types_8h.html#a12f3b5fd18ca108f90c5c74db602267e" title="define a break macro for debugging.">_IRR_DEBUG_BREAK_IF</a>(!used) <span class="comment">// access violation</span>
<a name="l00327"></a>00327 
<a name="l00328"></a>00328                 <span class="keywordflow">return</span> data[used-1];
<a name="l00329"></a>00329         }
<a name="l00330"></a>00330 
<a name="l00331"></a>00331 
<a name="l00333"></a><a class="code" href="classirr_1_1core_1_1array.html#ad531932175e210c17429878411490932">00333</a>         <span class="keyword">const</span> T&amp; <a class="code" href="classirr_1_1core_1_1array.html#ad87dc5db8bf6ec1033c945a0d3724e09" title="Gets last element.">getLast</a>()<span class="keyword"> const</span>
<a name="l00334"></a>00334 <span class="keyword">        </span>{
<a name="l00335"></a>00335                 <a class="code" href="irr_types_8h.html#a12f3b5fd18ca108f90c5c74db602267e" title="define a break macro for debugging.">_IRR_DEBUG_BREAK_IF</a>(!used) <span class="comment">// access violation</span>
<a name="l00336"></a>00336 
<a name="l00337"></a>00337                 <span class="keywordflow">return</span> data[used-1];
<a name="l00338"></a>00338         }
<a name="l00339"></a>00339 
<a name="l00340"></a>00340 
<a name="l00342"></a>00342 
<a name="l00343"></a><a class="code" href="classirr_1_1core_1_1array.html#a7b29797486e1c2ab3e7821082dab998c">00343</a>         T* <a class="code" href="classirr_1_1core_1_1array.html#a7b29797486e1c2ab3e7821082dab998c" title="Gets a pointer to the array.">pointer</a>()
<a name="l00344"></a>00344         {
<a name="l00345"></a>00345                 <span class="keywordflow">return</span> data;
<a name="l00346"></a>00346         }
<a name="l00347"></a>00347 
<a name="l00348"></a>00348 
<a name="l00350"></a>00350 
<a name="l00351"></a><a class="code" href="classirr_1_1core_1_1array.html#a8bf5bc844936a56632038524942f89f1">00351</a>         <span class="keyword">const</span> T* <a class="code" href="classirr_1_1core_1_1array.html#a8bf5bc844936a56632038524942f89f1" title="Gets a const pointer to the array.">const_pointer</a>()<span class="keyword"> const</span>
<a name="l00352"></a>00352 <span class="keyword">        </span>{
<a name="l00353"></a>00353                 <span class="keywordflow">return</span> data;
<a name="l00354"></a>00354         }
<a name="l00355"></a>00355 
<a name="l00356"></a>00356 
<a name="l00358"></a>00358 
<a name="l00359"></a><a class="code" href="classirr_1_1core_1_1array.html#abc592bab637d54799b6c86d6d0e8adf8">00359</a>         <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> <a class="code" href="classirr_1_1core_1_1array.html#abc592bab637d54799b6c86d6d0e8adf8" title="Get number of occupied elements of the array.">size</a>()<span class="keyword"> const</span>
<a name="l00360"></a>00360 <span class="keyword">        </span>{
<a name="l00361"></a>00361                 <span class="keywordflow">return</span> used;
<a name="l00362"></a>00362         }
<a name="l00363"></a>00363 
<a name="l00364"></a>00364 
<a name="l00366"></a>00366 
<a name="l00368"></a><a class="code" href="classirr_1_1core_1_1array.html#a2a15ea5df83792bce4366969d5b164c4">00368</a>         <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> <a class="code" href="classirr_1_1core_1_1array.html#a2a15ea5df83792bce4366969d5b164c4" title="Get amount of memory allocated.">allocated_size</a>()<span class="keyword"> const</span>
<a name="l00369"></a>00369 <span class="keyword">        </span>{
<a name="l00370"></a>00370                 <span class="keywordflow">return</span> allocated;
<a name="l00371"></a>00371         }
<a name="l00372"></a>00372 
<a name="l00373"></a>00373 
<a name="l00375"></a>00375 
<a name="l00376"></a><a class="code" href="classirr_1_1core_1_1array.html#a1de2f5999968e104bf0ec6f057f097c2">00376</a>         <span class="keywordtype">bool</span> <a class="code" href="classirr_1_1core_1_1array.html#a1de2f5999968e104bf0ec6f057f097c2" title="Check if array is empty.">empty</a>()<span class="keyword"> const</span>
<a name="l00377"></a>00377 <span class="keyword">        </span>{
<a name="l00378"></a>00378                 <span class="keywordflow">return</span> used == 0;
<a name="l00379"></a>00379         }
<a name="l00380"></a>00380 
<a name="l00381"></a>00381 
<a name="l00383"></a>00383 
<a name="l00385"></a><a class="code" href="classirr_1_1core_1_1array.html#a870e52dd57dd67a9d59e5ca5f82bca94">00385</a>         <span class="keywordtype">void</span> <a class="code" href="classirr_1_1core_1_1array.html#a870e52dd57dd67a9d59e5ca5f82bca94" title="Sorts the array using heapsort.">sort</a>()
<a name="l00386"></a>00386         {
<a name="l00387"></a>00387                 <span class="keywordflow">if</span> (!is_sorted &amp;&amp; used&gt;1)
<a name="l00388"></a>00388                         <a class="code" href="namespaceirr_1_1core.html#a4f062bd63b7d3048b4af2127e4a708c5" title="Sorts an array with size &amp;#39;size&amp;#39; using heapsort.">heapsort</a>(data, used);
<a name="l00389"></a>00389                 is_sorted = <span class="keyword">true</span>;
<a name="l00390"></a>00390         }
<a name="l00391"></a>00391 
<a name="l00392"></a>00392 
<a name="l00394"></a>00394 
<a name="l00400"></a><a class="code" href="classirr_1_1core_1_1array.html#a35412f669b983eaaf3792b82966db24a">00400</a>         <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> <a class="code" href="classirr_1_1core_1_1array.html#a35412f669b983eaaf3792b82966db24a" title="Performs a binary search for an element, returns -1 if not found.">binary_search</a>(<span class="keyword">const</span> T&amp; element)
<a name="l00401"></a>00401         {
<a name="l00402"></a>00402                 <a class="code" href="classirr_1_1core_1_1array.html#a870e52dd57dd67a9d59e5ca5f82bca94" title="Sorts the array using heapsort.">sort</a>();
<a name="l00403"></a>00403                 <span class="keywordflow">return</span> <a class="code" href="classirr_1_1core_1_1array.html#a35412f669b983eaaf3792b82966db24a" title="Performs a binary search for an element, returns -1 if not found.">binary_search</a>(element, 0, used-1);
<a name="l00404"></a>00404         }
<a name="l00405"></a>00405 
<a name="l00406"></a>00406 
<a name="l00408"></a>00408 
<a name="l00413"></a><a class="code" href="classirr_1_1core_1_1array.html#af9cd0644165ab0d40f97799acd3f2c22">00413</a>         <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> <a class="code" href="classirr_1_1core_1_1array.html#a35412f669b983eaaf3792b82966db24a" title="Performs a binary search for an element, returns -1 if not found.">binary_search</a>(<span class="keyword">const</span> T&amp; element)<span class="keyword"> const</span>
<a name="l00414"></a>00414 <span class="keyword">        </span>{
<a name="l00415"></a>00415                 <span class="keywordflow">if</span> (is_sorted)
<a name="l00416"></a>00416                         <span class="keywordflow">return</span> <a class="code" href="classirr_1_1core_1_1array.html#a35412f669b983eaaf3792b82966db24a" title="Performs a binary search for an element, returns -1 if not found.">binary_search</a>(element, 0, used-1);
<a name="l00417"></a>00417                 <span class="keywordflow">else</span>
<a name="l00418"></a>00418                         <span class="keywordflow">return</span> <a class="code" href="classirr_1_1core_1_1array.html#a06327f3b1a87117a57a617cbb7738beb" title="Finds an element in linear time, which is very slow.">linear_search</a>(element);
<a name="l00419"></a>00419         }
<a name="l00420"></a>00420 
<a name="l00421"></a>00421 
<a name="l00423"></a>00423 
<a name="l00428"></a><a class="code" href="classirr_1_1core_1_1array.html#ae2f68111b6899a63454d2956ee58ba6c">00428</a>         <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> <a class="code" href="classirr_1_1core_1_1array.html#a35412f669b983eaaf3792b82966db24a" title="Performs a binary search for an element, returns -1 if not found.">binary_search</a>(<span class="keyword">const</span> T&amp; element, <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> left, <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> right)<span class="keyword"> const</span>
<a name="l00429"></a>00429 <span class="keyword">        </span>{
<a name="l00430"></a>00430                 <span class="keywordflow">if</span> (!used)
<a name="l00431"></a>00431                         <span class="keywordflow">return</span> -1;
<a name="l00432"></a>00432 
<a name="l00433"></a>00433                 <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> m;
<a name="l00434"></a>00434 
<a name="l00435"></a>00435                 <span class="keywordflow">do</span>
<a name="l00436"></a>00436                 {
<a name="l00437"></a>00437                         m = (left+right)&gt;&gt;1;
<a name="l00438"></a>00438 
<a name="l00439"></a>00439                         <span class="keywordflow">if</span> (element &lt; data[m])
<a name="l00440"></a>00440                                 right = m - 1;
<a name="l00441"></a>00441                         <span class="keywordflow">else</span>
<a name="l00442"></a>00442                                 left = m + 1;
<a name="l00443"></a>00443 
<a name="l00444"></a>00444                 } <span class="keywordflow">while</span>((element &lt; data[m] || data[m] &lt; element) &amp;&amp; left&lt;=right);
<a name="l00445"></a>00445                 <span class="comment">// this last line equals to:</span>
<a name="l00446"></a>00446                 <span class="comment">// &quot; while((element != array[m]) &amp;&amp; left&lt;=right);&quot;</span>
<a name="l00447"></a>00447                 <span class="comment">// but we only want to use the &#39;&lt;&#39; operator.</span>
<a name="l00448"></a>00448                 <span class="comment">// the same in next line, it is &quot;(element == array[m])&quot;</span>
<a name="l00449"></a>00449 
<a name="l00450"></a>00450 
<a name="l00451"></a>00451                 <span class="keywordflow">if</span> (!(element &lt; data[m]) &amp;&amp; !(data[m] &lt; element))
<a name="l00452"></a>00452                         <span class="keywordflow">return</span> m;
<a name="l00453"></a>00453 
<a name="l00454"></a>00454                 <span class="keywordflow">return</span> -1;
<a name="l00455"></a>00455         }
<a name="l00456"></a>00456 
<a name="l00457"></a>00457 
<a name="l00460"></a>00460 
<a name="l00466"></a><a class="code" href="classirr_1_1core_1_1array.html#a62821cac92125dd76f96f21e60ca94a4">00466</a>         <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> <a class="code" href="classirr_1_1core_1_1array.html#a62821cac92125dd76f96f21e60ca94a4">binary_search_multi</a>(<span class="keyword">const</span> T&amp; element, <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> &amp;last)
<a name="l00467"></a>00467         {
<a name="l00468"></a>00468                 <a class="code" href="classirr_1_1core_1_1array.html#a870e52dd57dd67a9d59e5ca5f82bca94" title="Sorts the array using heapsort.">sort</a>();
<a name="l00469"></a>00469                 <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> index = <a class="code" href="classirr_1_1core_1_1array.html#a35412f669b983eaaf3792b82966db24a" title="Performs a binary search for an element, returns -1 if not found.">binary_search</a>(element, 0, used-1);
<a name="l00470"></a>00470                 <span class="keywordflow">if</span> ( index &lt; 0 )
<a name="l00471"></a>00471                         <span class="keywordflow">return</span> index;
<a name="l00472"></a>00472 
<a name="l00473"></a>00473                 <span class="comment">// The search can be somewhere in the middle of the set</span>
<a name="l00474"></a>00474                 <span class="comment">// look linear previous and past the index</span>
<a name="l00475"></a>00475                 last = index;
<a name="l00476"></a>00476 
<a name="l00477"></a>00477                 <span class="keywordflow">while</span> ( index &gt; 0 &amp;&amp; !(element &lt; data[index - 1]) &amp;&amp; !(data[index - 1] &lt; element) )
<a name="l00478"></a>00478                 {
<a name="l00479"></a>00479                         index -= 1;
<a name="l00480"></a>00480                 }
<a name="l00481"></a>00481                 <span class="comment">// look linear up</span>
<a name="l00482"></a>00482                 <span class="keywordflow">while</span> ( last &lt; (<a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a>) used - 1 &amp;&amp; !(element &lt; data[last + 1]) &amp;&amp; !(data[last + 1] &lt; element) )
<a name="l00483"></a>00483                 {
<a name="l00484"></a>00484                         last += 1;
<a name="l00485"></a>00485                 }
<a name="l00486"></a>00486 
<a name="l00487"></a>00487                 <span class="keywordflow">return</span> index;
<a name="l00488"></a>00488         }
<a name="l00489"></a>00489 
<a name="l00490"></a>00490 
<a name="l00492"></a>00492 
<a name="l00497"></a><a class="code" href="classirr_1_1core_1_1array.html#a06327f3b1a87117a57a617cbb7738beb">00497</a>         <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> <a class="code" href="classirr_1_1core_1_1array.html#a06327f3b1a87117a57a617cbb7738beb" title="Finds an element in linear time, which is very slow.">linear_search</a>(<span class="keyword">const</span> T&amp; element)<span class="keyword"> const</span>
<a name="l00498"></a>00498 <span class="keyword">        </span>{
<a name="l00499"></a>00499                 <span class="keywordflow">for</span> (<a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> i=0; i&lt;used; ++i)
<a name="l00500"></a>00500                         <span class="keywordflow">if</span> (element == data[i])
<a name="l00501"></a>00501                                 <span class="keywordflow">return</span> (<a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a>)i;
<a name="l00502"></a>00502 
<a name="l00503"></a>00503                 <span class="keywordflow">return</span> -1;
<a name="l00504"></a>00504         }
<a name="l00505"></a>00505 
<a name="l00506"></a>00506 
<a name="l00508"></a>00508 
<a name="l00513"></a><a class="code" href="classirr_1_1core_1_1array.html#ac4a756f807ae06a74cc71cfd05dc22de">00513</a>         <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> <a class="code" href="classirr_1_1core_1_1array.html#ac4a756f807ae06a74cc71cfd05dc22de" title="Finds an element in linear time, which is very slow.">linear_reverse_search</a>(<span class="keyword">const</span> T&amp; element)<span class="keyword"> const</span>
<a name="l00514"></a>00514 <span class="keyword">        </span>{
<a name="l00515"></a>00515                 <span class="keywordflow">for</span> (<a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> i=used-1; i&gt;=0; --i)
<a name="l00516"></a>00516                         <span class="keywordflow">if</span> (data[i] == element)
<a name="l00517"></a>00517                                 <span class="keywordflow">return</span> i;
<a name="l00518"></a>00518 
<a name="l00519"></a>00519                 <span class="keywordflow">return</span> -1;
<a name="l00520"></a>00520         }
<a name="l00521"></a>00521 
<a name="l00522"></a>00522 
<a name="l00524"></a>00524 
<a name="l00527"></a><a class="code" href="classirr_1_1core_1_1array.html#a5ba14e37dddaecd9c3e813a78c157dc8">00527</a>         <span class="keywordtype">void</span> <a class="code" href="classirr_1_1core_1_1array.html#a5ba14e37dddaecd9c3e813a78c157dc8" title="Erases an element from the array.">erase</a>(<a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> index)
<a name="l00528"></a>00528         {
<a name="l00529"></a>00529                 <a class="code" href="irr_types_8h.html#a12f3b5fd18ca108f90c5c74db602267e" title="define a break macro for debugging.">_IRR_DEBUG_BREAK_IF</a>(index&gt;=used) <span class="comment">// access violation</span>
<a name="l00530"></a>00530 
<a name="l00531"></a>00531                 <span class="keywordflow">for</span> (<a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> i=index+1; i&lt;used; ++i)
<a name="l00532"></a>00532                 {
<a name="l00533"></a>00533                         allocator.destruct(&amp;data[i-1]);
<a name="l00534"></a>00534                         allocator.construct(&amp;data[i-1], data[i]); <span class="comment">// data[i-1] = data[i];</span>
<a name="l00535"></a>00535                 }
<a name="l00536"></a>00536 
<a name="l00537"></a>00537                 allocator.destruct(&amp;data[used-1]);
<a name="l00538"></a>00538 
<a name="l00539"></a>00539                 --used;
<a name="l00540"></a>00540         }
<a name="l00541"></a>00541 
<a name="l00542"></a>00542 
<a name="l00544"></a>00544 
<a name="l00548"></a><a class="code" href="classirr_1_1core_1_1array.html#ab9bb8cb0e6ebc4839fa2f7bc8e626800">00548</a>         <span class="keywordtype">void</span> <a class="code" href="classirr_1_1core_1_1array.html#a5ba14e37dddaecd9c3e813a78c157dc8" title="Erases an element from the array.">erase</a>(<a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> index, <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> count)
<a name="l00549"></a>00549         {
<a name="l00550"></a>00550                 <span class="keywordflow">if</span> (index&gt;=used || count&lt;1)
<a name="l00551"></a>00551                         <span class="keywordflow">return</span>;
<a name="l00552"></a>00552                 <span class="keywordflow">if</span> (index+count&gt;used)
<a name="l00553"></a>00553                         count = used-index;
<a name="l00554"></a>00554 
<a name="l00555"></a>00555                 <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> i;
<a name="l00556"></a>00556                 <span class="keywordflow">for</span> (i=index; i&lt;index+count; ++i)
<a name="l00557"></a>00557                         allocator.destruct(&amp;data[i]);
<a name="l00558"></a>00558 
<a name="l00559"></a>00559                 <span class="keywordflow">for</span> (i=index+count; i&lt;used; ++i)
<a name="l00560"></a>00560                 {
<a name="l00561"></a>00561                         <span class="keywordflow">if</span> (i &gt; index+count)
<a name="l00562"></a>00562                                 allocator.destruct(&amp;data[i-count]);
<a name="l00563"></a>00563 
<a name="l00564"></a>00564                         allocator.construct(&amp;data[i-count], data[i]); <span class="comment">// data[i-count] = data[i];</span>
<a name="l00565"></a>00565 
<a name="l00566"></a>00566                         <span class="keywordflow">if</span> (i &gt;= used-count)
<a name="l00567"></a>00567                                 allocator.destruct(&amp;data[i]);
<a name="l00568"></a>00568                 }
<a name="l00569"></a>00569 
<a name="l00570"></a>00570                 used-= count;
<a name="l00571"></a>00571         }
<a name="l00572"></a>00572 
<a name="l00573"></a>00573 
<a name="l00575"></a><a class="code" href="classirr_1_1core_1_1array.html#ab73d5838db931996f66f9efcc7127b49">00575</a>         <span class="keywordtype">void</span> <a class="code" href="classirr_1_1core_1_1array.html#ab73d5838db931996f66f9efcc7127b49" title="Sets if the array is sorted.">set_sorted</a>(<span class="keywordtype">bool</span> _is_sorted)
<a name="l00576"></a>00576         {
<a name="l00577"></a>00577                 is_sorted = _is_sorted;
<a name="l00578"></a>00578         }
<a name="l00579"></a>00579 
<a name="l00580"></a>00580 
<a name="l00582"></a>00582 
<a name="l00585"></a><a class="code" href="classirr_1_1core_1_1array.html#a8857046f500a2990fc9930b204a3dbad">00585</a>         <span class="keywordtype">void</span> <a class="code" href="classirr_1_1core_1_1array.html#a8857046f500a2990fc9930b204a3dbad" title="Swap the content of this array container with the content of another array.">swap</a>(<a class="code" href="classirr_1_1core_1_1array.html" title="Self reallocating template array (like stl vector) with additional features.">array&lt;T, TAlloc&gt;</a>&amp; other)
<a name="l00586"></a>00586         {
<a name="l00587"></a>00587                 <a class="code" href="classirr_1_1core_1_1array.html#a8857046f500a2990fc9930b204a3dbad" title="Swap the content of this array container with the content of another array.">core::swap</a>(data, other.data);
<a name="l00588"></a>00588                 <a class="code" href="classirr_1_1core_1_1array.html#a8857046f500a2990fc9930b204a3dbad" title="Swap the content of this array container with the content of another array.">core::swap</a>(allocated, other.allocated);
<a name="l00589"></a>00589                 <a class="code" href="classirr_1_1core_1_1array.html#a8857046f500a2990fc9930b204a3dbad" title="Swap the content of this array container with the content of another array.">core::swap</a>(used, other.used);
<a name="l00590"></a>00590                 <a class="code" href="classirr_1_1core_1_1array.html#a8857046f500a2990fc9930b204a3dbad" title="Swap the content of this array container with the content of another array.">core::swap</a>(allocator, other.allocator); <span class="comment">// memory is still released by the same allocator used for allocation</span>
<a name="l00591"></a>00591                 <a class="code" href="namespaceirr_1_1core.html#aa2e91971d5e6e84de235bfabe3c7adba" title="defines an allocation strategy">eAllocStrategy</a> helper_strategy(strategy);       <span class="comment">// can&#39;t use core::swap with bitfields</span>
<a name="l00592"></a>00592                 strategy = other.strategy;
<a name="l00593"></a>00593                 other.strategy = helper_strategy;
<a name="l00594"></a>00594                 <span class="keywordtype">bool</span> helper_free_when_destroyed(free_when_destroyed);
<a name="l00595"></a>00595                 free_when_destroyed = other.free_when_destroyed;
<a name="l00596"></a>00596                 other.free_when_destroyed = helper_free_when_destroyed;
<a name="l00597"></a>00597                 <span class="keywordtype">bool</span> helper_is_sorted(is_sorted);
<a name="l00598"></a>00598                 is_sorted = other.is_sorted;
<a name="l00599"></a>00599                 other.is_sorted = helper_is_sorted;
<a name="l00600"></a>00600         }
<a name="l00601"></a>00601 
<a name="l00602"></a>00602 
<a name="l00603"></a>00603 <span class="keyword">private</span>:
<a name="l00604"></a>00604         T* data;
<a name="l00605"></a>00605         <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> allocated;
<a name="l00606"></a>00606         <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> used;
<a name="l00607"></a>00607         TAlloc allocator;
<a name="l00608"></a>00608         <a class="code" href="namespaceirr_1_1core.html#aa2e91971d5e6e84de235bfabe3c7adba" title="defines an allocation strategy">eAllocStrategy</a> strategy:4;
<a name="l00609"></a>00609         <span class="keywordtype">bool</span> free_when_destroyed:1;
<a name="l00610"></a>00610         <span class="keywordtype">bool</span> is_sorted:1;
<a name="l00611"></a>00611 };
<a name="l00612"></a>00612 
<a name="l00613"></a>00613 
<a name="l00614"></a>00614 } <span class="comment">// end namespace core</span>
<a name="l00615"></a>00615 } <span class="comment">// end namespace irr</span>
<a name="l00616"></a>00616 
<a name="l00617"></a>00617 <span class="preprocessor">#endif</span>
<a name="l00618"></a>00618 <span class="preprocessor"></span>
</pre></div></div>
<hr size="1">
<address style="align: right;">
<small> </small>
</address>
<table width="100%" border="0" cellspacing="0" cellpadding="2">
  <tr> 
    <td width="0"> <div align="left"><small><a href="http://irrlicht.sourceforge.net" target="_blank"><img src="irrlicht.png" alt="The Irrlicht Engine" align="middle" border=0 width=88 height=31></a></small></div></td>
    <td> <div align="left"><small><em><font size="2">The <a href="http://irrlicht.sourceforge.net" target="_blank">Irrlicht 
        Engine</a> Documentation &copy; 2003-2010 by Nikolaus Gebhardt. Generated 
        on Sun Oct 24 12:41:57 2010 by <a href="http://www.doxygen.org" target="_blank">Doxygen</a> 
        (1.6.2)</font></em></small></div></td>
  </tr>
</table>
<address style="align: right;">
</address>
</body>
</html>