1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
---|
2 | <html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> |
---|
3 | <title>mixpp: array.h Source File</title> |
---|
4 | <link href="tabs.css" rel="stylesheet" type="text/css"> |
---|
5 | <link href="doxygen.css" rel="stylesheet" type="text/css"> |
---|
6 | </head><body> |
---|
7 | <!-- Generated by Doxygen 1.5.8 --> |
---|
8 | <script type="text/javascript"> |
---|
9 | <!-- |
---|
10 | function changeDisplayState (e){ |
---|
11 | var num=this.id.replace(/[^[0-9]/g,''); |
---|
12 | var button=this.firstChild; |
---|
13 | var sectionDiv=document.getElementById('dynsection'+num); |
---|
14 | if (sectionDiv.style.display=='none'||sectionDiv.style.display==''){ |
---|
15 | sectionDiv.style.display='block'; |
---|
16 | button.src='open.gif'; |
---|
17 | }else{ |
---|
18 | sectionDiv.style.display='none'; |
---|
19 | button.src='closed.gif'; |
---|
20 | } |
---|
21 | } |
---|
22 | function initDynSections(){ |
---|
23 | var divs=document.getElementsByTagName('div'); |
---|
24 | var sectionCounter=1; |
---|
25 | for(var i=0;i<divs.length-1;i++){ |
---|
26 | if(divs[i].className=='dynheader'&&divs[i+1].className=='dynsection'){ |
---|
27 | var header=divs[i]; |
---|
28 | var section=divs[i+1]; |
---|
29 | var button=header.firstChild; |
---|
30 | if (button!='IMG'){ |
---|
31 | divs[i].insertBefore(document.createTextNode(' '),divs[i].firstChild); |
---|
32 | button=document.createElement('img'); |
---|
33 | divs[i].insertBefore(button,divs[i].firstChild); |
---|
34 | } |
---|
35 | header.style.cursor='pointer'; |
---|
36 | header.onclick=changeDisplayState; |
---|
37 | header.id='dynheader'+sectionCounter; |
---|
38 | button.src='closed.gif'; |
---|
39 | section.id='dynsection'+sectionCounter; |
---|
40 | section.style.display='none'; |
---|
41 | section.style.marginLeft='14px'; |
---|
42 | sectionCounter++; |
---|
43 | } |
---|
44 | } |
---|
45 | } |
---|
46 | window.onload = initDynSections; |
---|
47 | --> |
---|
48 | </script> |
---|
49 | <div class="navigation" id="top"> |
---|
50 | <div class="tabs"> |
---|
51 | <ul> |
---|
52 | <li><a href="main.html"><span>Main Page</span></a></li> |
---|
53 | <li><a href="pages.html"><span>Related Pages</span></a></li> |
---|
54 | <li><a href="modules.html"><span>Modules</span></a></li> |
---|
55 | <li><a href="annotated.html"><span>Classes</span></a></li> |
---|
56 | <li class="current"><a href="files.html"><span>Files</span></a></li> |
---|
57 | </ul> |
---|
58 | </div> |
---|
59 | <div class="tabs"> |
---|
60 | <ul> |
---|
61 | <li><a href="files.html"><span>File List</span></a></li> |
---|
62 | <li><a href="globals.html"><span>File Members</span></a></li> |
---|
63 | </ul> |
---|
64 | </div> |
---|
65 | <h1>array.h</h1><a href="array_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 |
---|
66 | <a name="l00029"></a>00029 <span class="preprocessor">#ifndef ARRAY_H</span> |
---|
67 | <a name="l00030"></a>00030 <span class="preprocessor"></span><span class="preprocessor">#define ARRAY_H</span> |
---|
68 | <a name="l00031"></a>00031 <span class="preprocessor"></span> |
---|
69 | <a name="l00032"></a>00032 <span class="preprocessor">#include <<a class="code" href="itassert_8h.html" title="Error handling functions - header file.">itpp/base/itassert.h</a>></span> |
---|
70 | <a name="l00033"></a>00033 <span class="preprocessor">#include <<a class="code" href="misc_8h.html" title="Miscellaneous functions - header file.">itpp/base/math/misc.h</a>></span> |
---|
71 | <a name="l00034"></a>00034 <span class="preprocessor">#include <<a class="code" href="factory_8h.html" title="Base class for class factories and memory allocation functions.">itpp/base/factory.h</a>></span> |
---|
72 | <a name="l00035"></a>00035 <span class="preprocessor">#include <<a class="code" href="copy__vector_8h.html" title="Vector copy functions for internal use.">itpp/base/copy_vector.h</a>></span> |
---|
73 | <a name="l00036"></a>00036 |
---|
74 | <a name="l00037"></a>00037 |
---|
75 | <a name="l00038"></a>00038 <span class="keyword">namespace </span>itpp |
---|
76 | <a name="l00039"></a>00039 { |
---|
77 | <a name="l00040"></a>00040 |
---|
78 | <a name="l00041"></a>00041 <span class="comment">// Forward declarations</span> |
---|
79 | <a name="l00042"></a>00042 <span class="keyword">template</span><<span class="keyword">class</span> T> <span class="keyword">class </span>Array; |
---|
80 | <a name="l00044"></a>00044 <span class="keyword">template</span><<span class="keyword">class</span> T> <span class="keyword">const</span> Array<T> concat(<span class="keyword">const</span> Array<T> &a, <span class="keyword">const</span> T e); |
---|
81 | <a name="l00046"></a>00046 <span class="keyword">template</span><<span class="keyword">class</span> T> <span class="keyword">const</span> Array<T> concat(<span class="keyword">const</span> T e, <span class="keyword">const</span> Array<T> &a); |
---|
82 | <a name="l00048"></a>00048 <span class="keyword">template</span><<span class="keyword">class</span> T> <span class="keyword">const</span> Array<T> concat(<span class="keyword">const</span> Array<T> &a1, |
---|
83 | <a name="l00049"></a>00049 <span class="keyword">const</span> Array<T> &a2); |
---|
84 | <a name="l00051"></a>00051 <span class="keyword">template</span><<span class="keyword">class</span> T> <span class="keyword">const</span> Array<T> concat(<span class="keyword">const</span> Array<T> &a1, |
---|
85 | <a name="l00052"></a>00052 <span class="keyword">const</span> Array<T> &a2, |
---|
86 | <a name="l00053"></a>00053 <span class="keyword">const</span> Array<T> &a3); |
---|
87 | <a name="l00054"></a>00054 |
---|
88 | <a name="l00103"></a>00103 <span class="keyword">template</span><<span class="keyword">class</span> T> |
---|
89 | <a name="l00104"></a><a class="code" href="classitpp_1_1Array.html">00104</a> <span class="keyword">class </span><a class="code" href="classitpp_1_1Array.html" title="General array class.">Array</a> |
---|
90 | <a name="l00105"></a>00105 { |
---|
91 | <a name="l00106"></a>00106 <span class="keyword">public</span>: |
---|
92 | <a name="l00108"></a>00108 <span class="keyword">explicit</span> <a class="code" href="classitpp_1_1Array.html#828caf09fa7e96b0985003276626276c" title="Default constructor. An element factory f can be specified.">Array</a>(<span class="keyword">const</span> <a class="code" href="classitpp_1_1Factory.html" title="Base class for class factories.">Factory</a> &f = DEFAULT_FACTORY); |
---|
93 | <a name="l00110"></a>00110 <a class="code" href="classitpp_1_1Array.html#828caf09fa7e96b0985003276626276c" title="Default constructor. An element factory f can be specified.">Array</a>(<span class="keywordtype">int</span> n, <span class="keyword">const</span> <a class="code" href="classitpp_1_1Factory.html" title="Base class for class factories.">Factory</a> &f = DEFAULT_FACTORY); |
---|
94 | <a name="l00112"></a>00112 <a class="code" href="classitpp_1_1Array.html#828caf09fa7e96b0985003276626276c" title="Default constructor. An element factory f can be specified.">Array</a>(<span class="keyword">const</span> <a class="code" href="classitpp_1_1Array.html" title="General array class.">Array<T></a> &a, <span class="keyword">const</span> <a class="code" href="classitpp_1_1Factory.html" title="Base class for class factories.">Factory</a> &f = DEFAULT_FACTORY); |
---|
95 | <a name="l00114"></a>00114 <a class="code" href="classitpp_1_1Array.html#828caf09fa7e96b0985003276626276c" title="Default constructor. An element factory f can be specified.">Array</a>(<span class="keyword">const</span> std::string& values, <span class="keyword">const</span> <a class="code" href="classitpp_1_1Factory.html" title="Base class for class factories.">Factory</a> &f = DEFAULT_FACTORY); |
---|
96 | <a name="l00116"></a>00116 <a class="code" href="classitpp_1_1Array.html#828caf09fa7e96b0985003276626276c" title="Default constructor. An element factory f can be specified.">Array</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* values, <span class="keyword">const</span> <a class="code" href="classitpp_1_1Factory.html" title="Base class for class factories.">Factory</a> &f = DEFAULT_FACTORY); |
---|
97 | <a name="l00117"></a>00117 |
---|
98 | <a name="l00119"></a>00119 <span class="keyword">virtual</span> <a class="code" href="classitpp_1_1Array.html#843ecbb3d82db87f6944104f485fd4d5" title="Destructor.">~Array</a>(); |
---|
99 | <a name="l00120"></a>00120 |
---|
100 | <a name="l00122"></a>00122 T &<a class="code" href="classitpp_1_1Array.html#c83fc47210a002a55dc70d67baeae32e" title="Get the i element.">operator()</a>(<span class="keywordtype">int</span> i); |
---|
101 | <a name="l00124"></a>00124 <span class="keyword">const</span> T &<a class="code" href="classitpp_1_1Array.html#c83fc47210a002a55dc70d67baeae32e" title="Get the i element.">operator()</a>(<span class="keywordtype">int</span> i) <span class="keyword">const</span>; |
---|
102 | <a name="l00126"></a>00126 <span class="keyword">const</span> <a class="code" href="classitpp_1_1Array.html" title="General array class.">Array<T></a> <a class="code" href="classitpp_1_1Array.html#c83fc47210a002a55dc70d67baeae32e" title="Get the i element.">operator()</a>(<span class="keywordtype">int</span> i1, <span class="keywordtype">int</span> i2) <span class="keyword">const</span>; |
---|
103 | <a name="l00128"></a>00128 <span class="keyword">const</span> <a class="code" href="classitpp_1_1Array.html" title="General array class.">Array<T></a> <a class="code" href="classitpp_1_1Array.html#c83fc47210a002a55dc70d67baeae32e" title="Get the i element.">operator()</a>(<span class="keyword">const</span> <a class="code" href="classitpp_1_1Array.html" title="General array class.">Array<int></a> &indices) <span class="keyword">const</span>; |
---|
104 | <a name="l00129"></a>00129 |
---|
105 | <a name="l00131"></a>00131 <a class="code" href="classitpp_1_1Array.html" title="General array class.">Array<T></a> <a class="code" href="classitpp_1_1Array.html#8d09b0d22f7c04c48c28f0748e1dedd4" title="Get n left elements of the array.">left</a>(<span class="keywordtype">int</span> n) <span class="keyword">const</span>; |
---|
106 | <a name="l00133"></a>00133 <a class="code" href="classitpp_1_1Array.html" title="General array class.">Array<T></a> <a class="code" href="classitpp_1_1Array.html#f538b0bbdd7777574cf0b70031df7eaa" title="Get n right elements of the array.">right</a>(<span class="keywordtype">int</span> n) <span class="keyword">const</span>; |
---|
107 | <a name="l00135"></a>00135 <a class="code" href="classitpp_1_1Array.html" title="General array class.">Array<T></a> <a class="code" href="classitpp_1_1Array.html#7f210bc941d1e75b6c2f9ab09d05e524" title="Get n elements of the array starting from pos.">mid</a>(<span class="keywordtype">int</span> pos, <span class="keywordtype">int</span> n) <span class="keyword">const</span>; |
---|
108 | <a name="l00136"></a>00136 |
---|
109 | <a name="l00138"></a>00138 <a class="code" href="classitpp_1_1Array.html" title="General array class.">Array<T></a>& <a class="code" href="classitpp_1_1Array.html#670cc48bfb09c05a50af9008650cc735" title="Assignment operator.">operator=</a>(<span class="keyword">const</span> T &e); |
---|
110 | <a name="l00140"></a>00140 <a class="code" href="classitpp_1_1Array.html" title="General array class.">Array<T></a>& <a class="code" href="classitpp_1_1Array.html#670cc48bfb09c05a50af9008650cc735" title="Assignment operator.">operator=</a>(<span class="keyword">const</span> <a class="code" href="classitpp_1_1Array.html" title="General array class.">Array<T></a> &a); |
---|
111 | <a name="l00142"></a>00142 <a class="code" href="classitpp_1_1Array.html" title="General array class.">Array<T></a>& <a class="code" href="classitpp_1_1Array.html#670cc48bfb09c05a50af9008650cc735" title="Assignment operator.">operator=</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* values); |
---|
112 | <a name="l00143"></a>00143 |
---|
113 | <a name="l00145"></a>00145 <span class="keyword">friend</span> <span class="keyword">const</span> <a class="code" href="classitpp_1_1Array.html" title="General array class.">Array<T></a> concat <>(<span class="keyword">const</span> <a class="code" href="classitpp_1_1Array.html" title="General array class.">Array<T></a> &a1, <span class="keyword">const</span> T e); |
---|
114 | <a name="l00147"></a>00147 <span class="keyword">friend</span> <span class="keyword">const</span> <a class="code" href="classitpp_1_1Array.html" title="General array class.">Array<T></a> concat <>(<span class="keyword">const</span> T e, <span class="keyword">const</span> <a class="code" href="classitpp_1_1Array.html" title="General array class.">Array<T></a> &a); |
---|
115 | <a name="l00149"></a>00149 <span class="keyword">friend</span> <span class="keyword">const</span> <a class="code" href="classitpp_1_1Array.html" title="General array class.">Array<T></a> concat <>(<span class="keyword">const</span> <a class="code" href="classitpp_1_1Array.html" title="General array class.">Array<T></a> &a1, <span class="keyword">const</span> <a class="code" href="classitpp_1_1Array.html" title="General array class.">Array<T></a> &a2); |
---|
116 | <a name="l00151"></a>00151 <span class="keyword">friend</span> <span class="keyword">const</span> <a class="code" href="classitpp_1_1Array.html" title="General array class.">Array<T></a> concat <>(<span class="keyword">const</span> <a class="code" href="classitpp_1_1Array.html" title="General array class.">Array<T></a> &a1, <span class="keyword">const</span> <a class="code" href="classitpp_1_1Array.html" title="General array class.">Array<T></a> &a2, |
---|
117 | <a name="l00152"></a>00152 <span class="keyword">const</span> <a class="code" href="classitpp_1_1Array.html" title="General array class.">Array<T></a> &a3); |
---|
118 | <a name="l00153"></a>00153 |
---|
119 | <a name="l00155"></a><a class="code" href="classitpp_1_1Array.html#ce6bb3089de6f3ff86806d78f35505a4">00155</a> <span class="keywordtype">int</span> <a class="code" href="classitpp_1_1Array.html#ce6bb3089de6f3ff86806d78f35505a4" title="Returns the number of data elements in the array object.">size</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="classitpp_1_1Array.html#5ed232605de7519ec8a7cd18ef33ea6a" title="The current number of elements in the Array.">ndata</a>; } |
---|
120 | <a name="l00157"></a><a class="code" href="classitpp_1_1Array.html#53629018f146084de506c33c69fa19a3">00157</a> <span class="keywordtype">int</span> <a class="code" href="classitpp_1_1Array.html#53629018f146084de506c33c69fa19a3" title="Returns the number of data elements in the array object.">length</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="classitpp_1_1Array.html#5ed232605de7519ec8a7cd18ef33ea6a" title="The current number of elements in the Array.">ndata</a>; } |
---|
121 | <a name="l00159"></a>00159 <span class="keywordtype">void</span> <a class="code" href="classitpp_1_1Array.html#dbf76c71f29014a4d53f254e83f3ff1c" title="Resizing an Array&lt;T&gt;.">set_size</a>(<span class="keywordtype">int</span> n, <span class="keywordtype">bool</span> copy = <span class="keyword">false</span>); |
---|
122 | <a name="l00161"></a><a class="code" href="classitpp_1_1Array.html#3709407656d26aae2c5d3e844316d4e0">00161</a> <span class="keywordtype">void</span> <a class="code" href="classitpp_1_1Array.html#3709407656d26aae2c5d3e844316d4e0" title="Resizing an Array&lt;T&gt;.">set_length</a>(<span class="keywordtype">int</span> n, <span class="keywordtype">bool</span> copy = <span class="keyword">false</span>) { <a class="code" href="classitpp_1_1Array.html#dbf76c71f29014a4d53f254e83f3ff1c" title="Resizing an Array&lt;T&gt;.">set_size</a>(n, copy); } |
---|
123 | <a name="l00162"></a>00162 |
---|
124 | <a name="l00164"></a>00164 T <a class="code" href="classitpp_1_1Array.html#953e9c8e8e5d3d8777bccb99c0c2ef03" title="Shift in data at position 0. Return data from the last position.">shift_right</a>(<span class="keyword">const</span> T& e); |
---|
125 | <a name="l00166"></a>00166 <span class="keyword">const</span> <a class="code" href="classitpp_1_1Array.html" title="General array class.">Array<T></a> <a class="code" href="classitpp_1_1Array.html#953e9c8e8e5d3d8777bccb99c0c2ef03" title="Shift in data at position 0. Return data from the last position.">shift_right</a>(<span class="keyword">const</span> <a class="code" href="classitpp_1_1Array.html" title="General array class.">Array<T></a> &a); |
---|
126 | <a name="l00168"></a>00168 T <a class="code" href="classitpp_1_1Array.html#82c1fc430eeef2fe5664ad68fb80f465" title="Shift in data at the last position. Return data from position 0.">shift_left</a>(<span class="keyword">const</span> T& e); |
---|
127 | <a name="l00170"></a>00170 <span class="keyword">const</span> <a class="code" href="classitpp_1_1Array.html" title="General array class.">Array<T></a> <a class="code" href="classitpp_1_1Array.html#82c1fc430eeef2fe5664ad68fb80f465" title="Shift in data at the last position. Return data from position 0.">shift_left</a>(<span class="keyword">const</span> <a class="code" href="classitpp_1_1Array.html" title="General array class.">Array<T></a> &a); |
---|
128 | <a name="l00172"></a>00172 <span class="keywordtype">void</span> <a class="code" href="classitpp_1_1Array.html#68c427966b7a5ffc25ff92f5ab1e8188" title="Swap elements i and j.">swap</a>(<span class="keywordtype">int</span> i, <span class="keywordtype">int</span> j); |
---|
129 | <a name="l00173"></a>00173 |
---|
130 | <a name="l00175"></a>00175 <span class="keywordtype">void</span> <a class="code" href="classitpp_1_1Array.html#77c84914c6c73bab1720300a3c37a700" title="Set the subarray defined by indicies i1 to i2 to Array&lt;T&gt; a.">set_subarray</a>(<span class="keywordtype">int</span> i1, <span class="keywordtype">int</span> i2, <span class="keyword">const</span> <a class="code" href="classitpp_1_1Array.html" title="General array class.">Array<T></a> &a); |
---|
131 | <a name="l00177"></a>00177 <span class="keywordtype">void</span> <a class="code" href="classitpp_1_1Array.html#77c84914c6c73bab1720300a3c37a700" title="Set the subarray defined by indicies i1 to i2 to Array&lt;T&gt; a.">set_subarray</a>(<span class="keywordtype">int</span> i1, <span class="keywordtype">int</span> i2, <span class="keyword">const</span> T t); |
---|
132 | <a name="l00178"></a>00178 |
---|
133 | <a name="l00179"></a>00179 <span class="keyword">protected</span>: |
---|
134 | <a name="l00181"></a>00181 <span class="keywordtype">void</span> <a class="code" href="classitpp_1_1Array.html#11d3a25f034298549ecd36f2d997f303" title="Allocate storage for an array of length n.">alloc</a>(<span class="keywordtype">int</span> n); |
---|
135 | <a name="l00183"></a>00183 <span class="keywordtype">void</span> <a class="code" href="classitpp_1_1Array.html#2f37242e1fadb8a011a11079eb0b28ed" title="Free the storage space allocated by the array.">free</a>(); |
---|
136 | <a name="l00185"></a><a class="code" href="classitpp_1_1Array.html#ff5bfdc700d2e218d585c1d82ec5035e">00185</a> <span class="keywordtype">bool</span> <a class="code" href="classitpp_1_1Array.html#ff5bfdc700d2e218d585c1d82ec5035e" title="Check whether index i is in the allowed range.">in_range</a>(<span class="keywordtype">int</span> i)<span class="keyword"> const </span>{ <span class="keywordflow">return</span> ((i < <a class="code" href="classitpp_1_1Array.html#5ed232605de7519ec8a7cd18ef33ea6a" title="The current number of elements in the Array.">ndata</a>) && (i >= 0)); } |
---|
137 | <a name="l00187"></a><a class="code" href="classitpp_1_1Array.html#5ed232605de7519ec8a7cd18ef33ea6a">00187</a> <span class="keywordtype">int</span> <a class="code" href="classitpp_1_1Array.html#5ed232605de7519ec8a7cd18ef33ea6a" title="The current number of elements in the Array.">ndata</a>; |
---|
138 | <a name="l00189"></a><a class="code" href="classitpp_1_1Array.html#d6ae1c2800467bc2a5895b70f1c76cf6">00189</a> T *<a class="code" href="classitpp_1_1Array.html#d6ae1c2800467bc2a5895b70f1c76cf6" title="A pointer to the data area.">data</a>; |
---|
139 | <a name="l00191"></a><a class="code" href="classitpp_1_1Array.html#79db0620d6f2512da65847033810e2b1">00191</a> <span class="keyword">const</span> <a class="code" href="classitpp_1_1Factory.html" title="Base class for class factories.">Factory</a> &<a class="code" href="classitpp_1_1Array.html#79db0620d6f2512da65847033810e2b1" title="Element factory (by default set to DEFAULT_FACTORY).">factory</a>; |
---|
140 | <a name="l00192"></a>00192 }; |
---|
141 | <a name="l00193"></a>00193 |
---|
142 | <a name="l00194"></a>00194 <span class="comment">// -------------------- Implementation starts here --------------------</span> |
---|
143 | <a name="l00195"></a>00195 |
---|
144 | <a name="l00196"></a>00196 <span class="keyword">template</span><<span class="keyword">class</span> T> <span class="keyword">inline</span> |
---|
145 | <a name="l00197"></a><a class="code" href="classitpp_1_1Array.html#11d3a25f034298549ecd36f2d997f303">00197</a> <span class="keywordtype">void</span> <a class="code" href="classitpp_1_1Array.html#11d3a25f034298549ecd36f2d997f303" title="Allocate storage for an array of length n.">Array<T>::alloc</a>(<span class="keywordtype">int</span> n) |
---|
146 | <a name="l00198"></a>00198 { |
---|
147 | <a name="l00199"></a>00199 <span class="keywordflow">if</span> (n > 0) { |
---|
148 | <a name="l00200"></a>00200 create_elements(<a class="code" href="classitpp_1_1Array.html#d6ae1c2800467bc2a5895b70f1c76cf6" title="A pointer to the data area.">data</a>, n, <a class="code" href="classitpp_1_1Array.html#79db0620d6f2512da65847033810e2b1" title="Element factory (by default set to DEFAULT_FACTORY).">factory</a>); |
---|
149 | <a name="l00201"></a>00201 <a class="code" href="classitpp_1_1Array.html#5ed232605de7519ec8a7cd18ef33ea6a" title="The current number of elements in the Array.">ndata</a> = n; |
---|
150 | <a name="l00202"></a>00202 } |
---|
151 | <a name="l00203"></a>00203 <span class="keywordflow">else</span> { |
---|
152 | <a name="l00204"></a>00204 <a class="code" href="classitpp_1_1Array.html#d6ae1c2800467bc2a5895b70f1c76cf6" title="A pointer to the data area.">data</a> = 0; |
---|
153 | <a name="l00205"></a>00205 <a class="code" href="classitpp_1_1Array.html#5ed232605de7519ec8a7cd18ef33ea6a" title="The current number of elements in the Array.">ndata</a> = 0; |
---|
154 | <a name="l00206"></a>00206 } |
---|
155 | <a name="l00207"></a>00207 } |
---|
156 | <a name="l00208"></a>00208 |
---|
157 | <a name="l00209"></a>00209 <span class="keyword">template</span><<span class="keyword">class</span> T> <span class="keyword">inline</span> |
---|
158 | <a name="l00210"></a><a class="code" href="classitpp_1_1Array.html#2f37242e1fadb8a011a11079eb0b28ed">00210</a> <span class="keywordtype">void</span> <a class="code" href="classitpp_1_1Array.html#2f37242e1fadb8a011a11079eb0b28ed" title="Free the storage space allocated by the array.">Array<T>::free</a>() |
---|
159 | <a name="l00211"></a>00211 { |
---|
160 | <a name="l00212"></a>00212 destroy_elements(<a class="code" href="classitpp_1_1Array.html#d6ae1c2800467bc2a5895b70f1c76cf6" title="A pointer to the data area.">data</a>, <a class="code" href="classitpp_1_1Array.html#5ed232605de7519ec8a7cd18ef33ea6a" title="The current number of elements in the Array.">ndata</a>); |
---|
161 | <a name="l00213"></a>00213 <a class="code" href="classitpp_1_1Array.html#5ed232605de7519ec8a7cd18ef33ea6a" title="The current number of elements in the Array.">ndata</a> = 0; |
---|
162 | <a name="l00214"></a>00214 } |
---|
163 | <a name="l00215"></a>00215 |
---|
164 | <a name="l00216"></a>00216 <span class="keyword">template</span><<span class="keyword">class</span> T> <span class="keyword">inline</span> |
---|
165 | <a name="l00217"></a><a class="code" href="classitpp_1_1Array.html#828caf09fa7e96b0985003276626276c">00217</a> <a class="code" href="classitpp_1_1Array.html#828caf09fa7e96b0985003276626276c" title="Default constructor. An element factory f can be specified.">Array<T>::Array</a>(<span class="keyword">const</span> <a class="code" href="classitpp_1_1Factory.html" title="Base class for class factories.">Factory</a> &f) : ndata(0), data(0), factory(f) {} |
---|
166 | <a name="l00218"></a>00218 |
---|
167 | <a name="l00219"></a>00219 <span class="keyword">template</span><<span class="keyword">class</span> T> <span class="keyword">inline</span> |
---|
168 | <a name="l00220"></a><a class="code" href="classitpp_1_1Array.html#1bd70bb31b1159af9ed654e9f4a9d67a">00220</a> <a class="code" href="classitpp_1_1Array.html#828caf09fa7e96b0985003276626276c" title="Default constructor. An element factory f can be specified.">Array<T>::Array</a>(<span class="keyword">const</span> <span class="keywordtype">int</span> n, <span class="keyword">const</span> <a class="code" href="classitpp_1_1Factory.html" title="Base class for class factories.">Factory</a> &f) : ndata(0), data(0), factory(f) |
---|
169 | <a name="l00221"></a>00221 { |
---|
170 | <a name="l00222"></a>00222 <a class="code" href="classitpp_1_1Array.html#11d3a25f034298549ecd36f2d997f303" title="Allocate storage for an array of length n.">alloc</a>(n); |
---|
171 | <a name="l00223"></a>00223 } |
---|
172 | <a name="l00224"></a>00224 |
---|
173 | <a name="l00225"></a>00225 <span class="keyword">template</span><<span class="keyword">class</span> T> <span class="keyword">inline</span> |
---|
174 | <a name="l00226"></a><a class="code" href="classitpp_1_1Array.html#4408d1e56c3223975eac1fce4eabcd4a">00226</a> <a class="code" href="classitpp_1_1Array.html#828caf09fa7e96b0985003276626276c" title="Default constructor. An element factory f can be specified.">Array<T>::Array</a>(<span class="keyword">const</span> <a class="code" href="classitpp_1_1Array.html" title="General array class.">Array<T></a> &a, <span class="keyword">const</span> <a class="code" href="classitpp_1_1Factory.html" title="Base class for class factories.">Factory</a> &f) |
---|
175 | <a name="l00227"></a>00227 : ndata(0), data(0), factory(f) |
---|
176 | <a name="l00228"></a>00228 { |
---|
177 | <a name="l00229"></a>00229 <a class="code" href="classitpp_1_1Array.html#11d3a25f034298549ecd36f2d997f303" title="Allocate storage for an array of length n.">alloc</a>(a.<a class="code" href="classitpp_1_1Array.html#5ed232605de7519ec8a7cd18ef33ea6a" title="The current number of elements in the Array.">ndata</a>); |
---|
178 | <a name="l00230"></a>00230 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i < a.<a class="code" href="classitpp_1_1Array.html#5ed232605de7519ec8a7cd18ef33ea6a" title="The current number of elements in the Array.">ndata</a>; i++) |
---|
179 | <a name="l00231"></a>00231 <a class="code" href="classitpp_1_1Array.html#d6ae1c2800467bc2a5895b70f1c76cf6" title="A pointer to the data area.">data</a>[i] = a.<a class="code" href="classitpp_1_1Array.html#d6ae1c2800467bc2a5895b70f1c76cf6" title="A pointer to the data area.">data</a>[i]; |
---|
180 | <a name="l00232"></a>00232 } |
---|
181 | <a name="l00233"></a>00233 |
---|
182 | <a name="l00234"></a>00234 <span class="keyword">template</span><<span class="keyword">class</span> T> <span class="keyword">inline</span> |
---|
183 | <a name="l00235"></a><a class="code" href="classitpp_1_1Array.html#d3ab6c8eb0e5ead62180f87f46b35165">00235</a> <a class="code" href="classitpp_1_1Array.html#828caf09fa7e96b0985003276626276c" title="Default constructor. An element factory f can be specified.">Array<T>::Array</a>(<span class="keyword">const</span> std::string& values, <span class="keyword">const</span> <a class="code" href="classitpp_1_1Factory.html" title="Base class for class factories.">Factory</a> &f) |
---|
184 | <a name="l00236"></a>00236 : ndata(0), data(0), factory(f) |
---|
185 | <a name="l00237"></a>00237 { |
---|
186 | <a name="l00238"></a>00238 std::istringstream buffer(values); |
---|
187 | <a name="l00239"></a>00239 buffer >> *<span class="keyword">this</span>; |
---|
188 | <a name="l00240"></a>00240 } |
---|
189 | <a name="l00241"></a>00241 |
---|
190 | <a name="l00242"></a>00242 <span class="keyword">template</span><<span class="keyword">class</span> T> <span class="keyword">inline</span> |
---|
191 | <a name="l00243"></a><a class="code" href="classitpp_1_1Array.html#883d46ec90a359695b506e1c604c8be5">00243</a> <a class="code" href="classitpp_1_1Array.html#828caf09fa7e96b0985003276626276c" title="Default constructor. An element factory f can be specified.">Array<T>::Array</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* values, <span class="keyword">const</span> <a class="code" href="classitpp_1_1Factory.html" title="Base class for class factories.">Factory</a> &f) |
---|
192 | <a name="l00244"></a>00244 : ndata(0), data(0), factory(f) |
---|
193 | <a name="l00245"></a>00245 { |
---|
194 | <a name="l00246"></a>00246 std::istringstream buffer(values); |
---|
195 | <a name="l00247"></a>00247 buffer >> *<span class="keyword">this</span>; |
---|
196 | <a name="l00248"></a>00248 } |
---|
197 | <a name="l00249"></a>00249 |
---|
198 | <a name="l00250"></a>00250 <span class="keyword">template</span><<span class="keyword">class</span> T> |
---|
199 | <a name="l00251"></a><a class="code" href="classitpp_1_1Array.html#843ecbb3d82db87f6944104f485fd4d5">00251</a> <a class="code" href="classitpp_1_1Array.html#843ecbb3d82db87f6944104f485fd4d5" title="Destructor.">Array<T>::~Array</a>() |
---|
200 | <a name="l00252"></a>00252 { |
---|
201 | <a name="l00253"></a>00253 <a class="code" href="classitpp_1_1Array.html#2f37242e1fadb8a011a11079eb0b28ed" title="Free the storage space allocated by the array.">free</a>(); |
---|
202 | <a name="l00254"></a>00254 } |
---|
203 | <a name="l00255"></a>00255 |
---|
204 | <a name="l00256"></a>00256 <span class="keyword">template</span><<span class="keyword">class</span> T> |
---|
205 | <a name="l00257"></a><a class="code" href="classitpp_1_1Array.html#dbf76c71f29014a4d53f254e83f3ff1c">00257</a> <span class="keywordtype">void</span> <a class="code" href="classitpp_1_1Array.html#dbf76c71f29014a4d53f254e83f3ff1c" title="Resizing an Array&lt;T&gt;.">Array<T>::set_size</a>(<span class="keywordtype">int</span> <a class="code" href="group__matrix__functions.html#g3c1a2b0972c6a8e1215eb3f76d7c7512" title="Length of vector.">size</a>, <span class="keywordtype">bool</span> copy) |
---|
206 | <a name="l00258"></a>00258 { |
---|
207 | <a name="l00259"></a>00259 <a class="code" href="group__errorhandlingfunc.html#gb319550e696ee9d824d23c2a176bc3a6" title="Abort if t is not true and NDEBUG is not defined.">it_assert_debug</a>(size >= 0, <span class="stringliteral">"Array::set_size(): New size must not be negative"</span>); |
---|
208 | <a name="l00260"></a>00260 <span class="keywordflow">if</span> (<a class="code" href="classitpp_1_1Array.html#5ed232605de7519ec8a7cd18ef33ea6a" title="The current number of elements in the Array.">ndata</a> == size) |
---|
209 | <a name="l00261"></a>00261 <span class="keywordflow">return</span>; |
---|
210 | <a name="l00262"></a>00262 <span class="keywordflow">if</span> (copy) { |
---|
211 | <a name="l00263"></a>00263 <span class="comment">// create a temporary pointer to the allocated data</span> |
---|
212 | <a name="l00264"></a>00264 T* tmp = <a class="code" href="classitpp_1_1Array.html#d6ae1c2800467bc2a5895b70f1c76cf6" title="A pointer to the data area.">data</a>; |
---|
213 | <a name="l00265"></a>00265 <span class="comment">// store the current number of elements</span> |
---|
214 | <a name="l00266"></a>00266 <span class="keywordtype">int</span> old_ndata = <a class="code" href="classitpp_1_1Array.html#5ed232605de7519ec8a7cd18ef33ea6a" title="The current number of elements in the Array.">ndata</a>; |
---|
215 | <a name="l00267"></a>00267 <span class="comment">// check how many elements we need to copy</span> |
---|
216 | <a name="l00268"></a>00268 <span class="keywordtype">int</span> <a class="code" href="group__protocol.html#g27dde5be5aac902c0de838b4b872cd2f" title="ADD DOCUMENTATION HERE.">min</a> = (<a class="code" href="classitpp_1_1Array.html#5ed232605de7519ec8a7cd18ef33ea6a" title="The current number of elements in the Array.">ndata</a> < size) ? <a class="code" href="classitpp_1_1Array.html#5ed232605de7519ec8a7cd18ef33ea6a" title="The current number of elements in the Array.">ndata</a> : size; |
---|
217 | <a name="l00269"></a>00269 <span class="comment">// allocate new memory</span> |
---|
218 | <a name="l00270"></a>00270 <a class="code" href="classitpp_1_1Array.html#11d3a25f034298549ecd36f2d997f303" title="Allocate storage for an array of length n.">alloc</a>(size); |
---|
219 | <a name="l00271"></a>00271 <span class="comment">// copy old elements into a new memory region</span> |
---|
220 | <a name="l00272"></a>00272 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i < min; ++i) { |
---|
221 | <a name="l00273"></a>00273 <a class="code" href="classitpp_1_1Array.html#d6ae1c2800467bc2a5895b70f1c76cf6" title="A pointer to the data area.">data</a>[i] = tmp[i]; |
---|
222 | <a name="l00274"></a>00274 } |
---|
223 | <a name="l00275"></a>00275 <span class="comment">// initialize the rest of resized array</span> |
---|
224 | <a name="l00276"></a>00276 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = min; i < size; ++i) { |
---|
225 | <a name="l00277"></a>00277 <a class="code" href="classitpp_1_1Array.html#d6ae1c2800467bc2a5895b70f1c76cf6" title="A pointer to the data area.">data</a>[i] = T(); |
---|
226 | <a name="l00278"></a>00278 } |
---|
227 | <a name="l00279"></a>00279 <span class="comment">// delete old elements</span> |
---|
228 | <a name="l00280"></a>00280 destroy_elements(tmp, old_ndata); |
---|
229 | <a name="l00281"></a>00281 } |
---|
230 | <a name="l00282"></a>00282 <span class="keywordflow">else</span> { |
---|
231 | <a name="l00283"></a>00283 <a class="code" href="classitpp_1_1Array.html#2f37242e1fadb8a011a11079eb0b28ed" title="Free the storage space allocated by the array.">free</a>(); |
---|
232 | <a name="l00284"></a>00284 <a class="code" href="classitpp_1_1Array.html#11d3a25f034298549ecd36f2d997f303" title="Allocate storage for an array of length n.">alloc</a>(size); |
---|
233 | <a name="l00285"></a>00285 } |
---|
234 | <a name="l00286"></a>00286 } |
---|
235 | <a name="l00287"></a>00287 |
---|
236 | <a name="l00288"></a>00288 |
---|
237 | <a name="l00289"></a>00289 <span class="keyword">template</span><<span class="keyword">class</span> T> <span class="keyword">inline</span> |
---|
238 | <a name="l00290"></a><a class="code" href="classitpp_1_1Array.html#c83fc47210a002a55dc70d67baeae32e">00290</a> T& <a class="code" href="classitpp_1_1Array.html#c83fc47210a002a55dc70d67baeae32e" title="Get the i element.">Array<T>::operator()</a>(<span class="keywordtype">int</span> i) |
---|
239 | <a name="l00291"></a>00291 { |
---|
240 | <a name="l00292"></a>00292 <a class="code" href="group__errorhandlingfunc.html#gb319550e696ee9d824d23c2a176bc3a6" title="Abort if t is not true and NDEBUG is not defined.">it_assert_debug</a>(<a class="code" href="classitpp_1_1Array.html#ff5bfdc700d2e218d585c1d82ec5035e" title="Check whether index i is in the allowed range.">in_range</a>(i), <span class="stringliteral">"Array::operator(): Improper index"</span>); |
---|
241 | <a name="l00293"></a>00293 <span class="keywordflow">return</span> <a class="code" href="classitpp_1_1Array.html#d6ae1c2800467bc2a5895b70f1c76cf6" title="A pointer to the data area.">data</a>[i]; |
---|
242 | <a name="l00294"></a>00294 } |
---|
243 | <a name="l00295"></a>00295 |
---|
244 | <a name="l00296"></a>00296 <span class="keyword">template</span><<span class="keyword">class</span> T> <span class="keyword">inline</span> |
---|
245 | <a name="l00297"></a><a class="code" href="classitpp_1_1Array.html#86cfb98d4c6f68c6c0e90ce871da2595">00297</a> <span class="keyword">const</span> T& <a class="code" href="classitpp_1_1Array.html#c83fc47210a002a55dc70d67baeae32e" title="Get the i element.">Array<T>::operator()</a>(<span class="keywordtype">int</span> i)<span class="keyword"> const</span> |
---|
246 | <a name="l00298"></a>00298 <span class="keyword"></span>{ |
---|
247 | <a name="l00299"></a>00299 <a class="code" href="group__errorhandlingfunc.html#gb319550e696ee9d824d23c2a176bc3a6" title="Abort if t is not true and NDEBUG is not defined.">it_assert_debug</a>(<a class="code" href="classitpp_1_1Array.html#ff5bfdc700d2e218d585c1d82ec5035e" title="Check whether index i is in the allowed range.">in_range</a>(i), <span class="stringliteral">"Array::operator(): Improper index"</span>); |
---|
248 | <a name="l00300"></a>00300 <span class="keywordflow">return</span> <a class="code" href="classitpp_1_1Array.html#d6ae1c2800467bc2a5895b70f1c76cf6" title="A pointer to the data area.">data</a>[i]; |
---|
249 | <a name="l00301"></a>00301 } |
---|
250 | <a name="l00302"></a>00302 |
---|
251 | <a name="l00303"></a>00303 <span class="keyword">template</span><<span class="keyword">class</span> T> <span class="keyword">inline</span> |
---|
252 | <a name="l00304"></a><a class="code" href="classitpp_1_1Array.html#6dec4bb1ef064de29e1024968c0f2d82">00304</a> <span class="keyword">const</span> <a class="code" href="classitpp_1_1Array.html" title="General array class.">Array<T></a> <a class="code" href="classitpp_1_1Array.html#c83fc47210a002a55dc70d67baeae32e" title="Get the i element.">Array<T>::operator()</a>(<span class="keywordtype">int</span> i1, <span class="keywordtype">int</span> i2)<span class="keyword"> const</span> |
---|
253 | <a name="l00305"></a>00305 <span class="keyword"></span>{ |
---|
254 | <a name="l00306"></a>00306 <a class="code" href="group__errorhandlingfunc.html#gb319550e696ee9d824d23c2a176bc3a6" title="Abort if t is not true and NDEBUG is not defined.">it_assert_debug</a>(<a class="code" href="classitpp_1_1Array.html#ff5bfdc700d2e218d585c1d82ec5035e" title="Check whether index i is in the allowed range.">in_range</a>(i1) && <a class="code" href="classitpp_1_1Array.html#ff5bfdc700d2e218d585c1d82ec5035e" title="Check whether index i is in the allowed range.">in_range</a>(i2) && (i2 >= i1), |
---|
255 | <a name="l00307"></a>00307 <span class="stringliteral">"Array::operator()(i1, i2): Improper indexes."</span>); |
---|
256 | <a name="l00308"></a>00308 <a class="code" href="classitpp_1_1Array.html" title="General array class.">Array<T></a> s(i2 - i1 + 1); |
---|
257 | <a name="l00309"></a>00309 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i < s.<a class="code" href="classitpp_1_1Array.html#5ed232605de7519ec8a7cd18ef33ea6a" title="The current number of elements in the Array.">ndata</a>; i++) |
---|
258 | <a name="l00310"></a>00310 s.<a class="code" href="classitpp_1_1Array.html#d6ae1c2800467bc2a5895b70f1c76cf6" title="A pointer to the data area.">data</a>[i] = <a class="code" href="classitpp_1_1Array.html#d6ae1c2800467bc2a5895b70f1c76cf6" title="A pointer to the data area.">data</a>[i1+i]; |
---|
259 | <a name="l00311"></a>00311 <span class="keywordflow">return</span> s; |
---|
260 | <a name="l00312"></a>00312 } |
---|
261 | <a name="l00313"></a>00313 |
---|
262 | <a name="l00314"></a>00314 <span class="keyword">template</span><<span class="keyword">class</span> T> <span class="keyword">inline</span> |
---|
263 | <a name="l00315"></a><a class="code" href="classitpp_1_1Array.html#a2aecb36ae3c2b5bf6a0d43ab610963a">00315</a> <span class="keyword">const</span> <a class="code" href="classitpp_1_1Array.html" title="General array class.">Array<T></a> <a class="code" href="classitpp_1_1Array.html#c83fc47210a002a55dc70d67baeae32e" title="Get the i element.">Array<T>::operator()</a>(<span class="keyword">const</span> <a class="code" href="classitpp_1_1Array.html" title="General array class.">Array<int></a> &indices)<span class="keyword"> const</span> |
---|
264 | <a name="l00316"></a>00316 <span class="keyword"></span>{ |
---|
265 | <a name="l00317"></a>00317 <a class="code" href="classitpp_1_1Array.html" title="General array class.">Array<T></a> a(indices.<a class="code" href="classitpp_1_1Array.html#ce6bb3089de6f3ff86806d78f35505a4" title="Returns the number of data elements in the array object.">size</a>()); |
---|
266 | <a name="l00318"></a>00318 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i < a.size(); i++) { |
---|
267 | <a name="l00319"></a>00319 <a class="code" href="group__errorhandlingfunc.html#gb319550e696ee9d824d23c2a176bc3a6" title="Abort if t is not true and NDEBUG is not defined.">it_assert_debug</a>(<a class="code" href="classitpp_1_1Array.html#ff5bfdc700d2e218d585c1d82ec5035e" title="Check whether index i is in the allowed range.">in_range</a>(indices(i)), |
---|
268 | <a name="l00320"></a>00320 <span class="stringliteral">"Array::operator()(indices): Improper indices."</span>); |
---|
269 | <a name="l00321"></a>00321 a(i) = <a class="code" href="classitpp_1_1Array.html#d6ae1c2800467bc2a5895b70f1c76cf6" title="A pointer to the data area.">data</a>[indices(i)]; |
---|
270 | <a name="l00322"></a>00322 } |
---|
271 | <a name="l00323"></a>00323 <span class="keywordflow">return</span> a; |
---|
272 | <a name="l00324"></a>00324 } |
---|
273 | <a name="l00325"></a>00325 |
---|
274 | <a name="l00326"></a>00326 <span class="keyword">template</span><<span class="keyword">class</span> T> <span class="keyword">inline</span> |
---|
275 | <a name="l00327"></a><a class="code" href="classitpp_1_1Array.html#3f6c72d82a1345777c423c336e7c3221">00327</a> <a class="code" href="classitpp_1_1Array.html" title="General array class.">Array<T></a>& <a class="code" href="classitpp_1_1Array.html#670cc48bfb09c05a50af9008650cc735" title="Assignment operator.">Array<T>::operator=</a>(<span class="keyword">const</span> <a class="code" href="classitpp_1_1Array.html" title="General array class.">Array<T></a> &a) |
---|
276 | <a name="l00328"></a>00328 { |
---|
277 | <a name="l00329"></a>00329 <span class="keywordflow">if</span> (<span class="keyword">this</span> != &a) { |
---|
278 | <a name="l00330"></a>00330 <a class="code" href="classitpp_1_1Array.html#dbf76c71f29014a4d53f254e83f3ff1c" title="Resizing an Array&lt;T&gt;.">set_size</a>(a.<a class="code" href="classitpp_1_1Array.html#5ed232605de7519ec8a7cd18ef33ea6a" title="The current number of elements in the Array.">ndata</a>); |
---|
279 | <a name="l00331"></a>00331 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i < <a class="code" href="classitpp_1_1Array.html#5ed232605de7519ec8a7cd18ef33ea6a" title="The current number of elements in the Array.">ndata</a>; i++) |
---|
280 | <a name="l00332"></a>00332 <a class="code" href="classitpp_1_1Array.html#d6ae1c2800467bc2a5895b70f1c76cf6" title="A pointer to the data area.">data</a>[i] = a.<a class="code" href="classitpp_1_1Array.html#d6ae1c2800467bc2a5895b70f1c76cf6" title="A pointer to the data area.">data</a>[i]; |
---|
281 | <a name="l00333"></a>00333 } |
---|
282 | <a name="l00334"></a>00334 <span class="keywordflow">return</span> *<span class="keyword">this</span>; |
---|
283 | <a name="l00335"></a>00335 } |
---|
284 | <a name="l00336"></a>00336 |
---|
285 | <a name="l00337"></a>00337 <span class="keyword">template</span><<span class="keyword">class</span> T> <span class="keyword">inline</span> |
---|
286 | <a name="l00338"></a><a class="code" href="classitpp_1_1Array.html#670cc48bfb09c05a50af9008650cc735">00338</a> <a class="code" href="classitpp_1_1Array.html" title="General array class.">Array<T></a>& <a class="code" href="classitpp_1_1Array.html#670cc48bfb09c05a50af9008650cc735" title="Assignment operator.">Array<T>::operator=</a>(<span class="keyword">const</span> T &e) |
---|
287 | <a name="l00339"></a>00339 { |
---|
288 | <a name="l00340"></a>00340 <span class="keywordflow">if</span> (<a class="code" href="classitpp_1_1Array.html#5ed232605de7519ec8a7cd18ef33ea6a" title="The current number of elements in the Array.">ndata</a> == 0) |
---|
289 | <a name="l00341"></a>00341 <a class="code" href="classitpp_1_1Array.html#dbf76c71f29014a4d53f254e83f3ff1c" title="Resizing an Array&lt;T&gt;.">set_size</a>(1); |
---|
290 | <a name="l00342"></a>00342 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i < <a class="code" href="classitpp_1_1Array.html#5ed232605de7519ec8a7cd18ef33ea6a" title="The current number of elements in the Array.">ndata</a>; i++) |
---|
291 | <a name="l00343"></a>00343 <a class="code" href="classitpp_1_1Array.html#d6ae1c2800467bc2a5895b70f1c76cf6" title="A pointer to the data area.">data</a>[i] = e; |
---|
292 | <a name="l00344"></a>00344 <span class="keywordflow">return</span> *<span class="keyword">this</span>; |
---|
293 | <a name="l00345"></a>00345 } |
---|
294 | <a name="l00346"></a>00346 |
---|
295 | <a name="l00347"></a>00347 <span class="keyword">template</span><<span class="keyword">class</span> T> |
---|
296 | <a name="l00348"></a><a class="code" href="classitpp_1_1Array.html#cec1b549e103508437214f61aede94f2">00348</a> <a class="code" href="classitpp_1_1Array.html" title="General array class.">Array<T></a>& <a class="code" href="classitpp_1_1Array.html#670cc48bfb09c05a50af9008650cc735" title="Assignment operator.">Array<T>::operator=</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* values) |
---|
297 | <a name="l00349"></a>00349 { |
---|
298 | <a name="l00350"></a>00350 std::istringstream buffer(values); |
---|
299 | <a name="l00351"></a>00351 buffer >> *<span class="keyword">this</span>; |
---|
300 | <a name="l00352"></a>00352 <span class="keywordflow">return</span> *<span class="keyword">this</span>; |
---|
301 | <a name="l00353"></a>00353 } |
---|
302 | <a name="l00354"></a>00354 |
---|
303 | <a name="l00355"></a>00355 |
---|
304 | <a name="l00356"></a>00356 <span class="keyword">template</span><<span class="keyword">class</span> T> |
---|
305 | <a name="l00357"></a><a class="code" href="classitpp_1_1Array.html#8d09b0d22f7c04c48c28f0748e1dedd4">00357</a> <a class="code" href="classitpp_1_1Array.html" title="General array class.">Array<T></a> <a class="code" href="classitpp_1_1Array.html#8d09b0d22f7c04c48c28f0748e1dedd4" title="Get n left elements of the array.">Array<T>::left</a>(<span class="keywordtype">int</span> n)<span class="keyword"> const</span> |
---|
306 | <a name="l00358"></a>00358 <span class="keyword"></span>{ |
---|
307 | <a name="l00359"></a>00359 <a class="code" href="group__errorhandlingfunc.html#gb319550e696ee9d824d23c2a176bc3a6" title="Abort if t is not true and NDEBUG is not defined.">it_assert_debug</a>(<a class="code" href="classitpp_1_1Array.html#ff5bfdc700d2e218d585c1d82ec5035e" title="Check whether index i is in the allowed range.">in_range</a>(n), <span class="stringliteral">"Array::left(): Index out of range"</span>); |
---|
308 | <a name="l00360"></a>00360 <a class="code" href="classitpp_1_1Array.html" title="General array class.">Array<T></a> tmp(n); |
---|
309 | <a name="l00361"></a>00361 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i < n; ++i) |
---|
310 | <a name="l00362"></a>00362 tmp.<a class="code" href="classitpp_1_1Array.html#d6ae1c2800467bc2a5895b70f1c76cf6" title="A pointer to the data area.">data</a>[i] = <a class="code" href="classitpp_1_1Array.html#d6ae1c2800467bc2a5895b70f1c76cf6" title="A pointer to the data area.">data</a>[i]; |
---|
311 | <a name="l00363"></a>00363 <span class="keywordflow">return</span> tmp; |
---|
312 | <a name="l00364"></a>00364 } |
---|
313 | <a name="l00365"></a>00365 |
---|
314 | <a name="l00366"></a>00366 <span class="keyword">template</span><<span class="keyword">class</span> T> |
---|
315 | <a name="l00367"></a><a class="code" href="classitpp_1_1Array.html#f538b0bbdd7777574cf0b70031df7eaa">00367</a> <a class="code" href="classitpp_1_1Array.html" title="General array class.">Array<T></a> <a class="code" href="classitpp_1_1Array.html#f538b0bbdd7777574cf0b70031df7eaa" title="Get n right elements of the array.">Array<T>::right</a>(<span class="keywordtype">int</span> n)<span class="keyword"> const</span> |
---|
316 | <a name="l00368"></a>00368 <span class="keyword"></span>{ |
---|
317 | <a name="l00369"></a>00369 <a class="code" href="group__errorhandlingfunc.html#gb319550e696ee9d824d23c2a176bc3a6" title="Abort if t is not true and NDEBUG is not defined.">it_assert_debug</a>(<a class="code" href="classitpp_1_1Array.html#ff5bfdc700d2e218d585c1d82ec5035e" title="Check whether index i is in the allowed range.">in_range</a>(n), <span class="stringliteral">"Array::right(): Index out of range"</span>); |
---|
318 | <a name="l00370"></a>00370 <a class="code" href="classitpp_1_1Array.html" title="General array class.">Array<T></a> tmp(n); |
---|
319 | <a name="l00371"></a>00371 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i < n; ++i) |
---|
320 | <a name="l00372"></a>00372 tmp.<a class="code" href="classitpp_1_1Array.html#d6ae1c2800467bc2a5895b70f1c76cf6" title="A pointer to the data area.">data</a>[i] = <a class="code" href="classitpp_1_1Array.html#d6ae1c2800467bc2a5895b70f1c76cf6" title="A pointer to the data area.">data</a>[<a class="code" href="classitpp_1_1Array.html#5ed232605de7519ec8a7cd18ef33ea6a" title="The current number of elements in the Array.">ndata</a>-n+i]; |
---|
321 | <a name="l00373"></a>00373 <span class="keywordflow">return</span> tmp; |
---|
322 | <a name="l00374"></a>00374 } |
---|
323 | <a name="l00375"></a>00375 |
---|
324 | <a name="l00376"></a>00376 <span class="keyword">template</span><<span class="keyword">class</span> T> |
---|
325 | <a name="l00377"></a><a class="code" href="classitpp_1_1Array.html#7f210bc941d1e75b6c2f9ab09d05e524">00377</a> <a class="code" href="classitpp_1_1Array.html" title="General array class.">Array<T></a> <a class="code" href="classitpp_1_1Array.html#7f210bc941d1e75b6c2f9ab09d05e524" title="Get n elements of the array starting from pos.">Array<T>::mid</a>(<span class="keywordtype">int</span> pos, <span class="keywordtype">int</span> n)<span class="keyword"> const</span> |
---|
326 | <a name="l00378"></a>00378 <span class="keyword"></span>{ |
---|
327 | <a name="l00379"></a>00379 <a class="code" href="group__errorhandlingfunc.html#gb319550e696ee9d824d23c2a176bc3a6" title="Abort if t is not true and NDEBUG is not defined.">it_assert_debug</a>((pos >= 0) && (n > 0) && (pos + n <= <a class="code" href="classitpp_1_1Array.html#5ed232605de7519ec8a7cd18ef33ea6a" title="The current number of elements in the Array.">ndata</a>), <span class="stringliteral">"Array::mid(): Indexing out of range"</span>); |
---|
328 | <a name="l00380"></a>00380 <a class="code" href="classitpp_1_1Array.html" title="General array class.">Array<T></a> tmp(n); |
---|
329 | <a name="l00381"></a>00381 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i < n; ++i) |
---|
330 | <a name="l00382"></a>00382 tmp.<a class="code" href="classitpp_1_1Array.html#d6ae1c2800467bc2a5895b70f1c76cf6" title="A pointer to the data area.">data</a>[i] = <a class="code" href="classitpp_1_1Array.html#d6ae1c2800467bc2a5895b70f1c76cf6" title="A pointer to the data area.">data</a>[pos+i]; |
---|
331 | <a name="l00383"></a>00383 <span class="keywordflow">return</span> tmp; |
---|
332 | <a name="l00384"></a>00384 } |
---|
333 | <a name="l00385"></a>00385 |
---|
334 | <a name="l00386"></a>00386 |
---|
335 | <a name="l00387"></a>00387 <span class="keyword">template</span><<span class="keyword">class</span> T> |
---|
336 | <a name="l00388"></a><a class="code" href="classitpp_1_1Array.html#953e9c8e8e5d3d8777bccb99c0c2ef03">00388</a> T <a class="code" href="classitpp_1_1Array.html#953e9c8e8e5d3d8777bccb99c0c2ef03" title="Shift in data at position 0. Return data from the last position.">Array<T>::shift_right</a>(<span class="keyword">const</span> T& x) |
---|
337 | <a name="l00389"></a>00389 { |
---|
338 | <a name="l00390"></a>00390 <a class="code" href="group__errorhandlingfunc.html#gb319550e696ee9d824d23c2a176bc3a6" title="Abort if t is not true and NDEBUG is not defined.">it_assert_debug</a>(<a class="code" href="classitpp_1_1Array.html#5ed232605de7519ec8a7cd18ef33ea6a" title="The current number of elements in the Array.">ndata</a> > 0, <span class="stringliteral">"Array::shift_right(x): Array empty!"</span>); |
---|
339 | <a name="l00391"></a>00391 T ret; |
---|
340 | <a name="l00392"></a>00392 |
---|
341 | <a name="l00393"></a>00393 ret = <a class="code" href="classitpp_1_1Array.html#d6ae1c2800467bc2a5895b70f1c76cf6" title="A pointer to the data area.">data</a>[<a class="code" href="classitpp_1_1Array.html#5ed232605de7519ec8a7cd18ef33ea6a" title="The current number of elements in the Array.">ndata</a>-1]; |
---|
342 | <a name="l00394"></a>00394 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = <a class="code" href="classitpp_1_1Array.html#5ed232605de7519ec8a7cd18ef33ea6a" title="The current number of elements in the Array.">ndata</a> - 1; i > 0; i--) |
---|
343 | <a name="l00395"></a>00395 <a class="code" href="classitpp_1_1Array.html#d6ae1c2800467bc2a5895b70f1c76cf6" title="A pointer to the data area.">data</a>[i] = <a class="code" href="classitpp_1_1Array.html#d6ae1c2800467bc2a5895b70f1c76cf6" title="A pointer to the data area.">data</a>[i-1]; |
---|
344 | <a name="l00396"></a>00396 <a class="code" href="classitpp_1_1Array.html#d6ae1c2800467bc2a5895b70f1c76cf6" title="A pointer to the data area.">data</a>[0] = x; |
---|
345 | <a name="l00397"></a>00397 |
---|
346 | <a name="l00398"></a>00398 <span class="keywordflow">return</span> ret; |
---|
347 | <a name="l00399"></a>00399 } |
---|
348 | <a name="l00400"></a>00400 |
---|
349 | <a name="l00401"></a>00401 |
---|
350 | <a name="l00402"></a>00402 <span class="keyword">template</span><<span class="keyword">class</span> T> |
---|
351 | <a name="l00403"></a><a class="code" href="classitpp_1_1Array.html#95c7113be8ffdb98b84471cef02f6e75">00403</a> <span class="keyword">const</span> <a class="code" href="classitpp_1_1Array.html" title="General array class.">Array<T></a> <a class="code" href="classitpp_1_1Array.html#953e9c8e8e5d3d8777bccb99c0c2ef03" title="Shift in data at position 0. Return data from the last position.">Array<T>::shift_right</a>(<span class="keyword">const</span> <a class="code" href="classitpp_1_1Array.html" title="General array class.">Array<T></a> &a) |
---|
352 | <a name="l00404"></a>00404 { |
---|
353 | <a name="l00405"></a>00405 <a class="code" href="group__errorhandlingfunc.html#gb319550e696ee9d824d23c2a176bc3a6" title="Abort if t is not true and NDEBUG is not defined.">it_assert_debug</a>(a.<a class="code" href="classitpp_1_1Array.html#5ed232605de7519ec8a7cd18ef33ea6a" title="The current number of elements in the Array.">ndata</a> <= <a class="code" href="classitpp_1_1Array.html#5ed232605de7519ec8a7cd18ef33ea6a" title="The current number of elements in the Array.">ndata</a>, <span class="stringliteral">"Array::shift_right(): Shift Array too large"</span>); |
---|
354 | <a name="l00406"></a>00406 <a class="code" href="classitpp_1_1Array.html" title="General array class.">Array<T></a> out(a.<a class="code" href="classitpp_1_1Array.html#5ed232605de7519ec8a7cd18ef33ea6a" title="The current number of elements in the Array.">ndata</a>); |
---|
355 | <a name="l00407"></a>00407 |
---|
356 | <a name="l00408"></a>00408 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i < a.<a class="code" href="classitpp_1_1Array.html#5ed232605de7519ec8a7cd18ef33ea6a" title="The current number of elements in the Array.">ndata</a>; i++) |
---|
357 | <a name="l00409"></a>00409 out.<a class="code" href="classitpp_1_1Array.html#d6ae1c2800467bc2a5895b70f1c76cf6" title="A pointer to the data area.">data</a>[i] = <a class="code" href="classitpp_1_1Array.html#d6ae1c2800467bc2a5895b70f1c76cf6" title="A pointer to the data area.">data</a>[<a class="code" href="classitpp_1_1Array.html#5ed232605de7519ec8a7cd18ef33ea6a" title="The current number of elements in the Array.">ndata</a>-a.<a class="code" href="classitpp_1_1Array.html#5ed232605de7519ec8a7cd18ef33ea6a" title="The current number of elements in the Array.">ndata</a>+i]; |
---|
358 | <a name="l00410"></a>00410 for (<span class="keywordtype">int</span> i = <a class="code" href="classitpp_1_1Array.html#5ed232605de7519ec8a7cd18ef33ea6a" title="The current number of elements in the Array.">ndata</a> - 1; i >= a.<a class="code" href="classitpp_1_1Array.html#5ed232605de7519ec8a7cd18ef33ea6a" title="The current number of elements in the Array.">ndata</a>; i--) |
---|
359 | <a name="l00411"></a>00411 <a class="code" href="classitpp_1_1Array.html#d6ae1c2800467bc2a5895b70f1c76cf6" title="A pointer to the data area.">data</a>[i] = <a class="code" href="classitpp_1_1Array.html#d6ae1c2800467bc2a5895b70f1c76cf6" title="A pointer to the data area.">data</a>[i-a.<a class="code" href="classitpp_1_1Array.html#5ed232605de7519ec8a7cd18ef33ea6a" title="The current number of elements in the Array.">ndata</a>]; |
---|
360 | <a name="l00412"></a>00412 for (<span class="keywordtype">int</span> i = 0; i < a.<a class="code" href="classitpp_1_1Array.html#5ed232605de7519ec8a7cd18ef33ea6a" title="The current number of elements in the Array.">ndata</a>; i++) |
---|
361 | <a name="l00413"></a>00413 <a class="code" href="classitpp_1_1Array.html#d6ae1c2800467bc2a5895b70f1c76cf6" title="A pointer to the data area.">data</a>[i] = a.<a class="code" href="classitpp_1_1Array.html#d6ae1c2800467bc2a5895b70f1c76cf6" title="A pointer to the data area.">data</a>[i]; |
---|
362 | <a name="l00414"></a>00414 |
---|
363 | <a name="l00415"></a>00415 <span class="keywordflow">return</span> out; |
---|
364 | <a name="l00416"></a>00416 } |
---|
365 | <a name="l00417"></a>00417 |
---|
366 | <a name="l00418"></a>00418 <span class="keyword">template</span><<span class="keyword">class</span> T> |
---|
367 | <a name="l00419"></a><a class="code" href="classitpp_1_1Array.html#82c1fc430eeef2fe5664ad68fb80f465">00419</a> T <a class="code" href="classitpp_1_1Array.html#82c1fc430eeef2fe5664ad68fb80f465" title="Shift in data at the last position. Return data from position 0.">Array<T>::shift_left</a>(<span class="keyword">const</span> T& x) |
---|
368 | <a name="l00420"></a>00420 { |
---|
369 | <a name="l00421"></a>00421 T temp = <a class="code" href="classitpp_1_1Array.html#d6ae1c2800467bc2a5895b70f1c76cf6" title="A pointer to the data area.">data</a>[0]; |
---|
370 | <a name="l00422"></a>00422 |
---|
371 | <a name="l00423"></a>00423 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i < <a class="code" href="classitpp_1_1Array.html#5ed232605de7519ec8a7cd18ef33ea6a" title="The current number of elements in the Array.">ndata</a> - 1; i++) |
---|
372 | <a name="l00424"></a>00424 <a class="code" href="classitpp_1_1Array.html#d6ae1c2800467bc2a5895b70f1c76cf6" title="A pointer to the data area.">data</a>[i] = <a class="code" href="classitpp_1_1Array.html#d6ae1c2800467bc2a5895b70f1c76cf6" title="A pointer to the data area.">data</a>[i+1]; |
---|
373 | <a name="l00425"></a>00425 <a class="code" href="classitpp_1_1Array.html#d6ae1c2800467bc2a5895b70f1c76cf6" title="A pointer to the data area.">data</a>[ndata-1] = x; |
---|
374 | <a name="l00426"></a>00426 |
---|
375 | <a name="l00427"></a>00427 <span class="keywordflow">return</span> temp; |
---|
376 | <a name="l00428"></a>00428 } |
---|
377 | <a name="l00429"></a>00429 |
---|
378 | <a name="l00430"></a>00430 <span class="keyword">template</span><<span class="keyword">class</span> T> |
---|
379 | <a name="l00431"></a><a class="code" href="classitpp_1_1Array.html#b5809a4bf63a413563799ea11584bff8">00431</a> <span class="keyword">const</span> <a class="code" href="classitpp_1_1Array.html" title="General array class.">Array<T></a> <a class="code" href="classitpp_1_1Array.html#82c1fc430eeef2fe5664ad68fb80f465" title="Shift in data at the last position. Return data from position 0.">Array<T>::shift_left</a>(<span class="keyword">const</span> <a class="code" href="classitpp_1_1Array.html" title="General array class.">Array<T></a> &a) |
---|
380 | <a name="l00432"></a>00432 { |
---|
381 | <a name="l00433"></a>00433 <a class="code" href="group__errorhandlingfunc.html#gb319550e696ee9d824d23c2a176bc3a6" title="Abort if t is not true and NDEBUG is not defined.">it_assert_debug</a>(a.<a class="code" href="classitpp_1_1Array.html#5ed232605de7519ec8a7cd18ef33ea6a" title="The current number of elements in the Array.">ndata</a> <= <a class="code" href="classitpp_1_1Array.html#5ed232605de7519ec8a7cd18ef33ea6a" title="The current number of elements in the Array.">ndata</a>, <span class="stringliteral">"Array::shift_left(): Shift Array too large"</span>); |
---|
382 | <a name="l00434"></a>00434 <a class="code" href="classitpp_1_1Array.html" title="General array class.">Array<T></a> out(a.<a class="code" href="classitpp_1_1Array.html#5ed232605de7519ec8a7cd18ef33ea6a" title="The current number of elements in the Array.">ndata</a>); |
---|
383 | <a name="l00435"></a>00435 |
---|
384 | <a name="l00436"></a>00436 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i < a.<a class="code" href="classitpp_1_1Array.html#5ed232605de7519ec8a7cd18ef33ea6a" title="The current number of elements in the Array.">ndata</a>; i++) |
---|
385 | <a name="l00437"></a>00437 out.<a class="code" href="classitpp_1_1Array.html#d6ae1c2800467bc2a5895b70f1c76cf6" title="A pointer to the data area.">data</a>[i] = <a class="code" href="classitpp_1_1Array.html#d6ae1c2800467bc2a5895b70f1c76cf6" title="A pointer to the data area.">data</a>[i]; |
---|
386 | <a name="l00438"></a>00438 for (<span class="keywordtype">int</span> i = 0; i < <a class="code" href="classitpp_1_1Array.html#5ed232605de7519ec8a7cd18ef33ea6a" title="The current number of elements in the Array.">ndata</a> - a.<a class="code" href="classitpp_1_1Array.html#5ed232605de7519ec8a7cd18ef33ea6a" title="The current number of elements in the Array.">ndata</a>; i++) |
---|
387 | <a name="l00439"></a>00439 <a class="code" href="classitpp_1_1Array.html#d6ae1c2800467bc2a5895b70f1c76cf6" title="A pointer to the data area.">data</a>[i] = <a class="code" href="classitpp_1_1Array.html#d6ae1c2800467bc2a5895b70f1c76cf6" title="A pointer to the data area.">data</a>[i+a.<a class="code" href="classitpp_1_1Array.html#5ed232605de7519ec8a7cd18ef33ea6a" title="The current number of elements in the Array.">ndata</a>]; |
---|
388 | <a name="l00440"></a>00440 for (<span class="keywordtype">int</span> i = <a class="code" href="classitpp_1_1Array.html#5ed232605de7519ec8a7cd18ef33ea6a" title="The current number of elements in the Array.">ndata</a> - a.<a class="code" href="classitpp_1_1Array.html#5ed232605de7519ec8a7cd18ef33ea6a" title="The current number of elements in the Array.">ndata</a>; i < <a class="code" href="classitpp_1_1Array.html#5ed232605de7519ec8a7cd18ef33ea6a" title="The current number of elements in the Array.">ndata</a>; i++) |
---|
389 | <a name="l00441"></a>00441 <a class="code" href="classitpp_1_1Array.html#d6ae1c2800467bc2a5895b70f1c76cf6" title="A pointer to the data area.">data</a>[i] = a.<a class="code" href="classitpp_1_1Array.html#d6ae1c2800467bc2a5895b70f1c76cf6" title="A pointer to the data area.">data</a>[i-<a class="code" href="classitpp_1_1Array.html#5ed232605de7519ec8a7cd18ef33ea6a" title="The current number of elements in the Array.">ndata</a>+a.<a class="code" href="classitpp_1_1Array.html#5ed232605de7519ec8a7cd18ef33ea6a" title="The current number of elements in the Array.">ndata</a>]; |
---|
390 | <a name="l00442"></a>00442 |
---|
391 | <a name="l00443"></a>00443 <span class="keywordflow">return</span> out; |
---|
392 | <a name="l00444"></a>00444 } |
---|
393 | <a name="l00445"></a>00445 |
---|
394 | <a name="l00446"></a>00446 <span class="keyword">template</span><<span class="keyword">class</span> T> |
---|
395 | <a name="l00447"></a><a class="code" href="classitpp_1_1Array.html#68c427966b7a5ffc25ff92f5ab1e8188">00447</a> <span class="keywordtype">void</span> <a class="code" href="classitpp_1_1Array.html#68c427966b7a5ffc25ff92f5ab1e8188" title="Swap elements i and j.">Array<T>::swap</a>(<span class="keywordtype">int</span> i, <span class="keywordtype">int</span> j) |
---|
396 | <a name="l00448"></a>00448 { |
---|
397 | <a name="l00449"></a>00449 <a class="code" href="group__errorhandlingfunc.html#gb319550e696ee9d824d23c2a176bc3a6" title="Abort if t is not true and NDEBUG is not defined.">it_assert_debug</a>(<a class="code" href="classitpp_1_1Array.html#ff5bfdc700d2e218d585c1d82ec5035e" title="Check whether index i is in the allowed range.">in_range</a>(i) && <a class="code" href="classitpp_1_1Array.html#ff5bfdc700d2e218d585c1d82ec5035e" title="Check whether index i is in the allowed range.">in_range</a>(j), |
---|
398 | <a name="l00450"></a>00450 <span class="stringliteral">"Array::swap(): Indices out of range."</span>); |
---|
399 | <a name="l00451"></a>00451 |
---|
400 | <a name="l00452"></a>00452 T temp = <a class="code" href="classitpp_1_1Array.html#d6ae1c2800467bc2a5895b70f1c76cf6" title="A pointer to the data area.">data</a>[i]; |
---|
401 | <a name="l00453"></a>00453 <a class="code" href="classitpp_1_1Array.html#d6ae1c2800467bc2a5895b70f1c76cf6" title="A pointer to the data area.">data</a>[i] = <a class="code" href="classitpp_1_1Array.html#d6ae1c2800467bc2a5895b70f1c76cf6" title="A pointer to the data area.">data</a>[j]; |
---|
402 | <a name="l00454"></a>00454 <a class="code" href="classitpp_1_1Array.html#d6ae1c2800467bc2a5895b70f1c76cf6" title="A pointer to the data area.">data</a>[j] = temp; |
---|
403 | <a name="l00455"></a>00455 } |
---|
404 | <a name="l00456"></a>00456 |
---|
405 | <a name="l00457"></a>00457 <span class="keyword">template</span><<span class="keyword">class</span> T> |
---|
406 | <a name="l00458"></a><a class="code" href="classitpp_1_1Array.html#77c84914c6c73bab1720300a3c37a700">00458</a> <span class="keywordtype">void</span> <a class="code" href="classitpp_1_1Array.html#77c84914c6c73bab1720300a3c37a700" title="Set the subarray defined by indicies i1 to i2 to Array&lt;T&gt; a.">Array<T>::set_subarray</a>(<span class="keywordtype">int</span> i1, <span class="keywordtype">int</span> i2, <span class="keyword">const</span> <a class="code" href="classitpp_1_1Array.html" title="General array class.">Array<T></a> &a) |
---|
407 | <a name="l00459"></a>00459 { |
---|
408 | <a name="l00460"></a>00460 <span class="keywordflow">if</span> (i1 == -1) i1 = <a class="code" href="classitpp_1_1Array.html#5ed232605de7519ec8a7cd18ef33ea6a" title="The current number of elements in the Array.">ndata</a> - 1; |
---|
409 | <a name="l00461"></a>00461 <span class="keywordflow">if</span> (i2 == -1) i2 = <a class="code" href="classitpp_1_1Array.html#5ed232605de7519ec8a7cd18ef33ea6a" title="The current number of elements in the Array.">ndata</a> - 1; |
---|
410 | <a name="l00462"></a>00462 |
---|
411 | <a name="l00463"></a>00463 <a class="code" href="group__errorhandlingfunc.html#gb319550e696ee9d824d23c2a176bc3a6" title="Abort if t is not true and NDEBUG is not defined.">it_assert_debug</a>(<a class="code" href="classitpp_1_1Array.html#ff5bfdc700d2e218d585c1d82ec5035e" title="Check whether index i is in the allowed range.">in_range</a>(i1) && <a class="code" href="classitpp_1_1Array.html#ff5bfdc700d2e218d585c1d82ec5035e" title="Check whether index i is in the allowed range.">in_range</a>(i2), |
---|
412 | <a name="l00464"></a>00464 <span class="stringliteral">"Array<T>::set_subarray(): Indices out of range."</span>); |
---|
413 | <a name="l00465"></a>00465 <a class="code" href="group__errorhandlingfunc.html#gb319550e696ee9d824d23c2a176bc3a6" title="Abort if t is not true and NDEBUG is not defined.">it_assert_debug</a>(i2 >= i1, <span class="stringliteral">"Array<T>::set_subarray(): i2 >= i1 necessary."</span>); |
---|
414 | <a name="l00466"></a>00466 <a class="code" href="group__errorhandlingfunc.html#gb319550e696ee9d824d23c2a176bc3a6" title="Abort if t is not true and NDEBUG is not defined.">it_assert_debug</a>(i2 - i1 + 1 == a.<a class="code" href="classitpp_1_1Array.html#5ed232605de7519ec8a7cd18ef33ea6a" title="The current number of elements in the Array.">ndata</a>, <span class="stringliteral">"Array<T>::set_subarray(): Wrong sizes."</span>); |
---|
415 | <a name="l00467"></a>00467 |
---|
416 | <a name="l00468"></a>00468 copy_vector(a.<a class="code" href="classitpp_1_1Array.html#5ed232605de7519ec8a7cd18ef33ea6a" title="The current number of elements in the Array.">ndata</a>, a.<a class="code" href="classitpp_1_1Array.html#d6ae1c2800467bc2a5895b70f1c76cf6" title="A pointer to the data area.">data</a>, <a class="code" href="classitpp_1_1Array.html#d6ae1c2800467bc2a5895b70f1c76cf6" title="A pointer to the data area.">data</a> + i1); |
---|
417 | <a name="l00469"></a>00469 } |
---|
418 | <a name="l00470"></a>00470 |
---|
419 | <a name="l00471"></a>00471 <span class="keyword">template</span><<span class="keyword">class</span> T> |
---|
420 | <a name="l00472"></a><a class="code" href="classitpp_1_1Array.html#fb9d105beea055bac5d5b5bcce2a41fd">00472</a> <span class="keywordtype">void</span> <a class="code" href="classitpp_1_1Array.html#77c84914c6c73bab1720300a3c37a700" title="Set the subarray defined by indicies i1 to i2 to Array&lt;T&gt; a.">Array<T>::set_subarray</a>(<span class="keywordtype">int</span> i1, <span class="keywordtype">int</span> i2, <span class="keyword">const</span> T t) |
---|
421 | <a name="l00473"></a>00473 { |
---|
422 | <a name="l00474"></a>00474 <span class="keywordflow">if</span> (i1 == -1) i1 = <a class="code" href="classitpp_1_1Array.html#5ed232605de7519ec8a7cd18ef33ea6a" title="The current number of elements in the Array.">ndata</a> - 1; |
---|
423 | <a name="l00475"></a>00475 <span class="keywordflow">if</span> (i2 == -1) i2 = <a class="code" href="classitpp_1_1Array.html#5ed232605de7519ec8a7cd18ef33ea6a" title="The current number of elements in the Array.">ndata</a> - 1; |
---|
424 | <a name="l00476"></a>00476 |
---|
425 | <a name="l00477"></a>00477 <a class="code" href="group__errorhandlingfunc.html#gb319550e696ee9d824d23c2a176bc3a6" title="Abort if t is not true and NDEBUG is not defined.">it_assert_debug</a>(<a class="code" href="classitpp_1_1Array.html#ff5bfdc700d2e218d585c1d82ec5035e" title="Check whether index i is in the allowed range.">in_range</a>(i1) && <a class="code" href="classitpp_1_1Array.html#ff5bfdc700d2e218d585c1d82ec5035e" title="Check whether index i is in the allowed range.">in_range</a>(i2), |
---|
426 | <a name="l00478"></a>00478 <span class="stringliteral">"Array<T>::set_subarray(): Indices out of range"</span>); |
---|
427 | <a name="l00479"></a>00479 <a class="code" href="group__errorhandlingfunc.html#gb319550e696ee9d824d23c2a176bc3a6" title="Abort if t is not true and NDEBUG is not defined.">it_assert_debug</a>(i2 >= i1, <span class="stringliteral">"Array<T>::set_subarray(): i2 >= i1 necessary"</span>); |
---|
428 | <a name="l00480"></a>00480 |
---|
429 | <a name="l00481"></a>00481 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = i1; i <= i2; i++) |
---|
430 | <a name="l00482"></a>00482 <a class="code" href="classitpp_1_1Array.html#d6ae1c2800467bc2a5895b70f1c76cf6" title="A pointer to the data area.">data</a>[i] = t; |
---|
431 | <a name="l00483"></a>00483 } |
---|
432 | <a name="l00484"></a>00484 |
---|
433 | <a name="l00485"></a>00485 <span class="keyword">template</span><<span class="keyword">class</span> T> |
---|
434 | <a name="l00486"></a>00486 <span class="keyword">const</span> <a class="code" href="classitpp_1_1Array.html" title="General array class.">Array<T></a> concat(<span class="keyword">const</span> <a class="code" href="classitpp_1_1Array.html" title="General array class.">Array<T></a> &a, <span class="keyword">const</span> T e) |
---|
435 | <a name="l00487"></a>00487 { |
---|
436 | <a name="l00488"></a>00488 <a class="code" href="classitpp_1_1Array.html" title="General array class.">Array<T></a> temp(a.<a class="code" href="classitpp_1_1Array.html#ce6bb3089de6f3ff86806d78f35505a4" title="Returns the number of data elements in the array object.">size</a>() + 1); |
---|
437 | <a name="l00489"></a>00489 |
---|
438 | <a name="l00490"></a>00490 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i < a.<a class="code" href="classitpp_1_1Array.html#ce6bb3089de6f3ff86806d78f35505a4" title="Returns the number of data elements in the array object.">size</a>(); i++) |
---|
439 | <a name="l00491"></a>00491 temp(i) = a(i); |
---|
440 | <a name="l00492"></a>00492 temp(a.<a class="code" href="classitpp_1_1Array.html#ce6bb3089de6f3ff86806d78f35505a4" title="Returns the number of data elements in the array object.">size</a>()) = e; |
---|
441 | <a name="l00493"></a>00493 |
---|
442 | <a name="l00494"></a>00494 <span class="keywordflow">return</span> temp; |
---|
443 | <a name="l00495"></a>00495 } |
---|
444 | <a name="l00496"></a>00496 |
---|
445 | <a name="l00497"></a>00497 <span class="keyword">template</span><<span class="keyword">class</span> T> |
---|
446 | <a name="l00498"></a>00498 <span class="keyword">const</span> Array<T> concat(<span class="keyword">const</span> T e, <span class="keyword">const</span> Array<T> &a) |
---|
447 | <a name="l00499"></a>00499 { |
---|
448 | <a name="l00500"></a>00500 Array<T> temp(a.size() + 1); |
---|
449 | <a name="l00501"></a>00501 |
---|
450 | <a name="l00502"></a>00502 temp(0) = e; |
---|
451 | <a name="l00503"></a>00503 |
---|
452 | <a name="l00504"></a>00504 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i < a.size(); i++) |
---|
453 | <a name="l00505"></a>00505 temp(i + 1) = a(i); |
---|
454 | <a name="l00506"></a>00506 |
---|
455 | <a name="l00507"></a>00507 <span class="keywordflow">return</span> temp; |
---|
456 | <a name="l00508"></a>00508 } |
---|
457 | <a name="l00509"></a>00509 |
---|
458 | <a name="l00510"></a>00510 <span class="keyword">template</span><<span class="keyword">class</span> T> |
---|
459 | <a name="l00511"></a>00511 <span class="keyword">const</span> Array<T> concat(<span class="keyword">const</span> Array<T> &a1, <span class="keyword">const</span> Array<T> &a2) |
---|
460 | <a name="l00512"></a>00512 { |
---|
461 | <a name="l00513"></a>00513 Array<T> temp(a1.size() + a2.size()); |
---|
462 | <a name="l00514"></a>00514 |
---|
463 | <a name="l00515"></a>00515 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i < a1.size(); i++) |
---|
464 | <a name="l00516"></a>00516 temp(i) = a1(i); |
---|
465 | <a name="l00517"></a>00517 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i < a2.size(); i++) |
---|
466 | <a name="l00518"></a>00518 temp(a1.size() + i) = a2(i); |
---|
467 | <a name="l00519"></a>00519 |
---|
468 | <a name="l00520"></a>00520 <span class="keywordflow">return</span> temp; |
---|
469 | <a name="l00521"></a>00521 } |
---|
470 | <a name="l00522"></a>00522 |
---|
471 | <a name="l00523"></a>00523 <span class="keyword">template</span><<span class="keyword">class</span> T> |
---|
472 | <a name="l00524"></a>00524 <span class="keyword">const</span> Array<T> concat(<span class="keyword">const</span> Array<T> &a1, <span class="keyword">const</span> Array<T> &a2, |
---|
473 | <a name="l00525"></a>00525 <span class="keyword">const</span> Array<T> &a3) |
---|
474 | <a name="l00526"></a>00526 { |
---|
475 | <a name="l00527"></a>00527 <span class="comment">// There should be some error control?</span> |
---|
476 | <a name="l00528"></a>00528 Array<T> temp(a1.size() + a2.size() + a3.size()); |
---|
477 | <a name="l00529"></a>00529 |
---|
478 | <a name="l00530"></a>00530 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i < a1.size(); i++) |
---|
479 | <a name="l00531"></a>00531 temp(i) = a1(i); |
---|
480 | <a name="l00532"></a>00532 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i < a2.size(); i++) |
---|
481 | <a name="l00533"></a>00533 temp(a1.size() + i) = a2(i); |
---|
482 | <a name="l00534"></a>00534 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i < a3.size(); i++) |
---|
483 | <a name="l00535"></a>00535 temp(a1.size() + a2.size() + i) = a3(i); |
---|
484 | <a name="l00536"></a>00536 |
---|
485 | <a name="l00537"></a>00537 <span class="keywordflow">return</span> temp; |
---|
486 | <a name="l00538"></a>00538 } |
---|
487 | <a name="l00539"></a>00539 |
---|
488 | <a name="l00544"></a>00544 <span class="keyword">template</span><<span class="keyword">class</span> T> |
---|
489 | <a name="l00545"></a><a class="code" href="classitpp_1_1Array.html#527a6c86b076ffe554452697e19b8f60">00545</a> std::ostream &operator<<(std::ostream &os, const Array<T> &a) |
---|
490 | <a name="l00546"></a>00546 { |
---|
491 | <a name="l00547"></a>00547 os << <span class="stringliteral">"{"</span>; |
---|
492 | <a name="l00548"></a>00548 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i < a.size() - 1; i++) |
---|
493 | <a name="l00549"></a>00549 os << a(i) << <span class="stringliteral">" "</span>; |
---|
494 | <a name="l00550"></a>00550 <span class="keywordflow">if</span> (a.size() > 0) |
---|
495 | <a name="l00551"></a>00551 os << a(a.size() - 1); |
---|
496 | <a name="l00552"></a>00552 os << <span class="stringliteral">"}"</span>; |
---|
497 | <a name="l00553"></a>00553 |
---|
498 | <a name="l00554"></a>00554 <span class="keywordflow">return</span> os; |
---|
499 | <a name="l00555"></a>00555 } |
---|
500 | <a name="l00556"></a>00556 |
---|
501 | <a name="l00561"></a>00561 <span class="keyword">template</span><<span class="keyword">class</span> T> |
---|
502 | <a name="l00562"></a><a class="code" href="classitpp_1_1Array.html#fe07b04bfe22532f04c5584abd66de56">00562</a> std::istream &<a class="code" href="group__fixed.html#gbd223815e04b623a044d98fd366f3a0f" title="Input bit representation and, optionally, the shift.">operator>></a>(std::istream &is, <a class="code" href="classitpp_1_1Array.html" title="General array class.">Array<T></a> &a) |
---|
503 | <a name="l00563"></a>00563 { |
---|
504 | <a name="l00564"></a>00564 <span class="keywordtype">int</span> nrof_elements = 0; |
---|
505 | <a name="l00565"></a>00565 <span class="keywordtype">char</span> c; |
---|
506 | <a name="l00566"></a>00566 is >> c; |
---|
507 | <a name="l00567"></a>00567 <span class="keywordflow">if</span> (c == <span class="charliteral">'{'</span>) { |
---|
508 | <a name="l00568"></a>00568 is >> c; |
---|
509 | <a name="l00569"></a>00569 <span class="keywordflow">while</span> (c != <span class="charliteral">'}'</span>) { |
---|
510 | <a name="l00570"></a>00570 <span class="keywordflow">if</span> (is.eof()) { |
---|
511 | <a name="l00571"></a>00571 is.setstate(std::ios_base::failbit); |
---|
512 | <a name="l00572"></a>00572 <span class="keywordflow">break</span>; |
---|
513 | <a name="l00573"></a>00573 } |
---|
514 | <a name="l00574"></a>00574 <span class="keywordflow">if</span> (c != <span class="charliteral">','</span>) { <span class="comment">// Discard comma signs between elements</span> |
---|
515 | <a name="l00575"></a>00575 is.putback(c); |
---|
516 | <a name="l00576"></a>00576 } |
---|
517 | <a name="l00577"></a>00577 <span class="keywordflow">if</span> (++nrof_elements > a.<a class="code" href="classitpp_1_1Array.html#ce6bb3089de6f3ff86806d78f35505a4" title="Returns the number of data elements in the array object.">size</a>()) { |
---|
518 | <a name="l00578"></a>00578 a.<a class="code" href="classitpp_1_1Array.html#dbf76c71f29014a4d53f254e83f3ff1c" title="Resizing an Array&lt;T&gt;.">set_size</a>(nrof_elements, <span class="keyword">true</span>); <span class="comment">// Too slow?</span> |
---|
519 | <a name="l00579"></a>00579 } |
---|
520 | <a name="l00580"></a>00580 is >> a(nrof_elements - 1); |
---|
521 | <a name="l00581"></a>00581 is >> c; |
---|
522 | <a name="l00582"></a>00582 } |
---|
523 | <a name="l00583"></a>00583 <span class="keywordflow">if</span> (a.<a class="code" href="classitpp_1_1Array.html#ce6bb3089de6f3ff86806d78f35505a4" title="Returns the number of data elements in the array object.">size</a>() > nrof_elements) { |
---|
524 | <a name="l00584"></a>00584 a.<a class="code" href="classitpp_1_1Array.html#dbf76c71f29014a4d53f254e83f3ff1c" title="Resizing an Array&lt;T&gt;.">set_size</a>(nrof_elements, <span class="keyword">true</span>); |
---|
525 | <a name="l00585"></a>00585 } |
---|
526 | <a name="l00586"></a>00586 } |
---|
527 | <a name="l00587"></a>00587 <span class="keywordflow">else</span> { |
---|
528 | <a name="l00588"></a>00588 is.setstate(std::ios_base::failbit); |
---|
529 | <a name="l00589"></a>00589 } |
---|
530 | <a name="l00590"></a>00590 |
---|
531 | <a name="l00591"></a>00591 <span class="keywordflow">return</span> is; |
---|
532 | <a name="l00592"></a>00592 } |
---|
533 | <a name="l00593"></a>00593 |
---|
534 | <a name="l00599"></a>00599 <span class="keyword">template</span><<span class="keyword">class</span> T> |
---|
535 | <a name="l00600"></a><a class="code" href="classitpp_1_1Array.html#67cb651aaaef00b3ee8f642e1c644542">00600</a> <span class="keywordtype">void</span> set_array(<a class="code" href="classitpp_1_1Array.html" title="General array class.">Array<T></a> &a, <span class="keyword">const</span> <span class="keywordtype">char</span> *values) |
---|
536 | <a name="l00601"></a>00601 { |
---|
537 | <a name="l00602"></a>00602 std::istringstream buffer(values); |
---|
538 | <a name="l00603"></a>00603 buffer >> a; |
---|
539 | <a name="l00604"></a>00604 } |
---|
540 | <a name="l00605"></a>00605 |
---|
541 | <a name="l00611"></a>00611 <span class="keyword">template</span><<span class="keyword">class</span> T> |
---|
542 | <a name="l00612"></a><a class="code" href="classitpp_1_1Array.html#c86e8aff5f332b77c8ffe680b56ddcf9">00612</a> <span class="keywordtype">void</span> set_array(<a class="code" href="classitpp_1_1Array.html" title="General array class.">Array<T></a> &a, <span class="keyword">const</span> std::string &str) |
---|
543 | <a name="l00613"></a>00613 { |
---|
544 | <a name="l00614"></a>00614 set_array(a, str.c_str()); |
---|
545 | <a name="l00615"></a>00615 } |
---|
546 | <a name="l00616"></a>00616 |
---|
547 | <a name="l00617"></a>00617 } <span class="comment">// namespace itpp</span> |
---|
548 | <a name="l00618"></a>00618 |
---|
549 | <a name="l00619"></a>00619 <span class="preprocessor">#endif // #ifndef ARRAY_H</span> |
---|
550 | </pre></div></div> |
---|
551 | <hr size="1"><address style="text-align: right;"><small>Generated on Tue Jun 2 10:02:10 2009 for mixpp by |
---|
552 | <a href="http://www.doxygen.org/index.html"> |
---|
553 | <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.8 </small></address> |
---|
554 | </body> |
---|
555 | </html> |
---|