source: NonGTP/FCollada/Documentation/_f_m_array_8h-source.html @ 964

Revision 964, 9.8 KB checked in by igarcia, 18 years ago (diff)
Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
3<title>FCollada: FMath/FMArray.h Source File</title>
4<link href="doxygen.css" rel="stylesheet" type="text/css">
5<link href="tabs.css" rel="stylesheet" type="text/css">
6</head><body>
7<!-- Generated by Doxygen 1.4.6-NO -->
8<div class="tabs">
9  <ul>
10    <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
11    <li><a href="modules.html"><span>Modules</span></a></li>
12    <li><a href="namespaces.html"><span>Namespaces</span></a></li>
13    <li><a href="classes.html"><span>Classes</span></a></li>
14    <li id="current"><a href="files.html"><span>Files</span></a></li>
15    <li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
16  </ul></div>
17<div class="tabs">
18  <ul>
19    <li><a href="files.html"><span>File&nbsp;List</span></a></li>
20    <li><a href="globals.html"><span>File&nbsp;Members</span></a></li>
21  </ul></div>
22<h1>FMath/FMArray.h</h1><a href="_f_m_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">/*</span>
23<a name="l00002"></a>00002 <span class="comment">    Copyright (C) 2005-2006 Feeling Software Inc.</span>
24<a name="l00003"></a>00003 <span class="comment">    MIT License: http://www.opensource.org/licenses/mit-license.php</span>
25<a name="l00004"></a>00004 <span class="comment">*/</span>
26<a name="l00005"></a>00005
27<a name="l00020"></a>00020 <span class="preprocessor">#ifndef _FM_ARRAY_H_</span>
28<a name="l00021"></a>00021 <span class="preprocessor"></span><span class="preprocessor">#define _FM_ARRAY_H_</span>
29<a name="l00022"></a>00022 <span class="preprocessor"></span>
30<a name="l00023"></a>00023 <span class="keyword">template</span> &lt;<span class="keyword">class</span> T&gt;
31<a name="l00024"></a><a class="code" href="classvector.html">00024</a> <span class="keyword">class </span>FCOLLADA_EXPORT <a class="code" href="classvector.html">vector</a> : <span class="keyword">public</span> std::<a class="code" href="classvector.html">vector</a>&lt;T&gt;
32<a name="l00025"></a>00025 {
33<a name="l00026"></a>00026 <span class="keyword">public</span>:
34<a name="l00028"></a><a class="code" href="classvector.html#00d237f22fd5eb1aa9a536993e82e54f">00028</a>     <a class="code" href="classvector.html#00d237f22fd5eb1aa9a536993e82e54f">vector</a>() : std::<a class="code" href="classvector.html">vector</a>&lt;T&gt;() {}
35<a name="l00029"></a>00029
36<a name="l00032"></a><a class="code" href="classvector.html#3cf10ee7159dfcd1064bfd84a1eee5b9">00032</a>     <a class="code" href="classvector.html#00d237f22fd5eb1aa9a536993e82e54f">vector</a>(size_t size) : std::<a class="code" href="classvector.html">vector</a>&lt;T&gt;(size) {}
37<a name="l00033"></a>00033
38<a name="l00037"></a><a class="code" href="classvector.html#ba97da948950e44cce86e0120221b485">00037</a>     <a class="code" href="classvector.html#00d237f22fd5eb1aa9a536993e82e54f">vector</a>(size_t size, <span class="keyword">const</span> T&amp; defaultValue) : std::<a class="code" href="classvector.html">vector</a>&lt;T&gt;(size, defaultValue) {}
39<a name="l00038"></a>00038
40<a name="l00041"></a><a class="code" href="classvector.html#660e3e68d9c63fbd94f1fce19e81fc6a">00041</a>     <a class="code" href="classvector.html#00d237f22fd5eb1aa9a536993e82e54f">vector</a>(<span class="keyword">const</span> std::vector&amp; copy) : std::<a class="code" href="classvector.html">vector</a>&lt;T&gt;(copy) {}
41<a name="l00042"></a>00042
42<a name="l00046"></a><a class="code" href="classvector.html#7168cb7468dc4c26338cef3625583474">00046</a>     <a class="code" href="classvector.html#00d237f22fd5eb1aa9a536993e82e54f">vector</a>(<span class="keyword">const</span> T* values, size_t count) : std::<a class="code" href="classvector.html">vector</a>&lt;T&gt;()
43<a name="l00047"></a>00047     {
44<a name="l00048"></a>00048         resize(count);
45<a name="l00049"></a>00049         memcpy(&amp;at(0), values, count * <span class="keyword">sizeof</span>(T));
46<a name="l00050"></a>00050     }
47<a name="l00051"></a>00051
48<a name="l00056"></a>00056 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> _T&gt;
49<a name="l00057"></a><a class="code" href="classvector.html#00c4d8fce908b64c9eb805dc37afb458">00057</a>     <span class="keyword">inline</span> iterator <a class="code" href="classvector.html#00c4d8fce908b64c9eb805dc37afb458">find</a>(<span class="keyword">const</span> _T&amp; value) { <span class="keywordflow">return</span> std::find(begin(), end(), value); }
50<a name="l00058"></a>00058 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> _T&gt;
51<a name="l00059"></a><a class="code" href="classvector.html#0461a6982868798239a4f92d23a7d797">00059</a>     <span class="keyword">inline</span> const_iterator <a class="code" href="classvector.html#00c4d8fce908b64c9eb805dc37afb458">find</a>(<span class="keyword">const</span> _T&amp; value)<span class="keyword"> const </span>{ <span class="keywordflow">return</span> std::find(begin(), end(), value); }
52<a name="l00063"></a><a class="code" href="classvector.html#a001aee5cdea3ab9078a4d34b8a7b216">00063</a>     <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="classvector.html#a001aee5cdea3ab9078a4d34b8a7b216">erase</a>(iterator it) { std::vector&lt;T&gt;::erase(it); }
53<a name="l00064"></a>00064
54<a name="l00067"></a><a class="code" href="classvector.html#422bfaab14978bc0324e7c9483e00123">00067</a>     <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="classvector.html#a001aee5cdea3ab9078a4d34b8a7b216">erase</a>(iterator first, iterator last) { std::vector&lt;T&gt;::erase(first, last); }
55<a name="l00068"></a>00068
56<a name="l00072"></a><a class="code" href="classvector.html#15e2710e61daf283afcf4a11c3a9e325">00072</a>     <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code" href="classvector.html#a001aee5cdea3ab9078a4d34b8a7b216">erase</a>(<span class="keyword">const</span> T&amp; value) { iterator it = <a class="code" href="classvector.html#00c4d8fce908b64c9eb805dc37afb458">find</a>(value); <span class="keywordflow">if</span> (it != end()) { <a class="code" href="classvector.html#a001aee5cdea3ab9078a4d34b8a7b216">erase</a>(it); <span class="keywordflow">return</span> <span class="keyword">true</span>; } <span class="keywordflow">return</span> <span class="keyword">false</span>; }
57<a name="l00073"></a>00073
58<a name="l00076"></a><a class="code" href="classvector.html#51bb78c4da81421022d2368e15de15e4">00076</a>     <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="classvector.html#a001aee5cdea3ab9078a4d34b8a7b216">erase</a>(size_t index) { <a class="code" href="classvector.html#a001aee5cdea3ab9078a4d34b8a7b216">erase</a>(begin() + index); }
59<a name="l00077"></a>00077
60<a name="l00083"></a><a class="code" href="classvector.html#c819ae18b5b7c82e41ec3d470993430a">00083</a>     <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code" href="classvector.html#c819ae18b5b7c82e41ec3d470993430a">release</a>(<span class="keyword">const</span> T&amp; value) { iterator it = <a class="code" href="classvector.html#00c4d8fce908b64c9eb805dc37afb458">find</a>(value); <span class="keywordflow">if</span> (it != end()) { <a class="code" href="classvector.html#a001aee5cdea3ab9078a4d34b8a7b216">erase</a>(it); <span class="keyword">delete</span> value; <span class="keywordflow">return</span> <span class="keyword">true</span>; } <span class="keywordflow">return</span> <span class="keyword">false</span>; }
61<a name="l00084"></a>00084
62<a name="l00087"></a><a class="code" href="classvector.html#a0603dbd3b02ecb677cb1b41df32c4f9">00087</a>     <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code" href="classvector.html#a0603dbd3b02ecb677cb1b41df32c4f9">contains</a>(<span class="keyword">const</span> T&amp; value)<span class="keyword"> const </span>{ const_iterator it = <a class="code" href="classvector.html#00c4d8fce908b64c9eb805dc37afb458">find</a>(value); <span class="keywordflow">return</span> it != end(); }
63<a name="l00088"></a>00088 };
64<a name="l00089"></a>00089
65<a name="l00095"></a>00095 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> T&gt;
66<a name="l00096"></a><a class="code" href="_f_m_array_8h.html#10854668923860f01d22d6f543c34cb2">00096</a> <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code" href="_f_m_array_8h.html#10854668923860f01d22d6f543c34cb2">IsEquivalent</a>(<span class="keyword">const</span> <a class="code" href="classvector.html">vector&lt;T&gt;</a>&amp; dl, <span class="keyword">const</span> T* cl, size_t count)
67<a name="l00097"></a>00097 {
68<a name="l00098"></a>00098 <span class="keywordflow">if</span> (dl.size() != count) <span class="keywordflow">return</span> <span class="keyword">false</span>;
69<a name="l00099"></a>00099 <span class="keywordtype">bool</span> equivalent = <span class="keyword">true</span>;
70<a name="l00100"></a>00100 <span class="keywordflow">for</span> (size_t i = 0; i &lt; count &amp;&amp; equivalent; ++i) equivalent = <a class="code" href="_f_m_array_8h.html#10854668923860f01d22d6f543c34cb2">IsEquivalent</a>(dl.at(i), cl[i]);
71<a name="l00101"></a>00101 <span class="keywordflow">return</span> equivalent;
72<a name="l00102"></a>00102 }
73<a name="l00103"></a>00103
74<a name="l00104"></a>00104 <span class="preprocessor">#endif // _FM_ARRAY_H_</span>
75</pre></div><hr size="1"><address style="align: right;"><small>Generated on Fri May 12 16:44:39 2006 for FCollada by&nbsp;
76<a href="http://www.doxygen.org/index.html">
77<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.6-NO </small></address>
78</body>
79</html>
Note: See TracBrowser for help on using the repository browser.