aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/others/irrlicht-1.8.1/doc/html/heapsort_8h_source.html
diff options
context:
space:
mode:
Diffstat (limited to 'src/others/irrlicht-1.8.1/doc/html/heapsort_8h_source.html')
-rw-r--r--src/others/irrlicht-1.8.1/doc/html/heapsort_8h_source.html188
1 files changed, 188 insertions, 0 deletions
diff --git a/src/others/irrlicht-1.8.1/doc/html/heapsort_8h_source.html b/src/others/irrlicht-1.8.1/doc/html/heapsort_8h_source.html
new file mode 100644
index 0000000..72072a5
--- /dev/null
+++ b/src/others/irrlicht-1.8.1/doc/html/heapsort_8h_source.html
@@ -0,0 +1,188 @@
1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2<html xmlns="http://www.w3.org/1999/xhtml">
3<head>
4<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
5<title>Irrlicht 3D Engine: heapsort.h Source File</title>
6
7<link href="tabs.css" rel="stylesheet" type="text/css"/>
8<link href="doxygen.css" rel="stylesheet" type="text/css" />
9<link href="navtree.css" rel="stylesheet" type="text/css"/>
10<script type="text/javascript" src="jquery.js"></script>
11<script type="text/javascript" src="resize.js"></script>
12<script type="text/javascript" src="navtree.js"></script>
13<script type="text/javascript">
14 $(document).ready(initResizable);
15</script>
16<link href="search/search.css" rel="stylesheet" type="text/css"/>
17<script type="text/javascript" src="search/search.js"></script>
18<script type="text/javascript">
19 $(document).ready(function() { searchBox.OnSelectItem(0); });
20</script>
21
22</head>
23<body>
24<div id="top"><!-- do not remove this div! -->
25
26
27<div id="titlearea">
28<table cellspacing="0" cellpadding="0">
29 <tbody>
30 <tr style="height: 56px;">
31
32 <td id="projectlogo"><img alt="Logo" src="irrlichtlogo.png"/></td>
33
34
35 <td style="padding-left: 0.5em;">
36 <div id="projectname">Irrlicht 3D Engine
37
38 </div>
39
40 </td>
41
42
43
44
45 <td> <div id="MSearchBox" class="MSearchBoxInactive">
46 <span class="left">
47 <img id="MSearchSelect" src="search/mag_sel.png"
48 onmouseover="return searchBox.OnSearchSelectShow()"
49 onmouseout="return searchBox.OnSearchSelectHide()"
50 alt=""/>
51 <input type="text" id="MSearchField" value="Search" accesskey="S"
52 onfocus="searchBox.OnSearchFieldFocus(true)"
53 onblur="searchBox.OnSearchFieldFocus(false)"
54 onkeyup="searchBox.OnSearchFieldChange(event)"/>
55 </span><span class="right">
56 <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
57 </span>
58 </div>
59</td>
60
61
62 </tr>
63 </tbody>
64</table>
65</div>
66
67<!-- Generated by Doxygen 1.7.5.1 -->
68<script type="text/javascript">
69var searchBox = new SearchBox("searchBox", "search",false,'Search');
70</script>
71<script type="text/javascript" src="dynsections.js"></script>
72</div>
73<div id="side-nav" class="ui-resizable side-nav-resizable">
74 <div id="nav-tree">
75 <div id="nav-tree-contents">
76 </div>
77 </div>
78 <div id="splitbar" style="-moz-user-select:none;"
79 class="ui-resizable-handle">
80 </div>
81</div>
82<script type="text/javascript">
83 initNavTree('heapsort_8h.html','');
84</script>
85<div id="doc-content">
86<div class="header">
87 <div class="headertitle">
88<div class="title">heapsort.h</div> </div>
89</div>
90<div class="contents">
91<a href="heapsort_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">// Copyright (C) 2002-2012 Nikolaus Gebhardt</span>
92<a name="l00002"></a>00002 <span class="comment">// This file is part of the &quot;Irrlicht Engine&quot;.</span>
93<a name="l00003"></a>00003 <span class="comment">// For conditions of distribution and use, see copyright notice in irrlicht.h</span>
94<a name="l00004"></a>00004
95<a name="l00005"></a>00005 <span class="preprocessor">#ifndef __IRR_HEAPSORT_H_INCLUDED__</span>
96<a name="l00006"></a>00006 <span class="preprocessor"></span><span class="preprocessor">#define __IRR_HEAPSORT_H_INCLUDED__</span>
97<a name="l00007"></a>00007 <span class="preprocessor"></span>
98<a name="l00008"></a>00008 <span class="preprocessor">#include &quot;<a class="code" href="irr_types_8h.html">irrTypes.h</a>&quot;</span>
99<a name="l00009"></a>00009
100<a name="l00010"></a>00010 <span class="keyword">namespace </span>irr
101<a name="l00011"></a>00011 {
102<a name="l00012"></a>00012 <span class="keyword">namespace </span>core
103<a name="l00013"></a>00013 {
104<a name="l00014"></a>00014
105<a name="l00016"></a>00016 <span class="keyword">template</span>&lt;<span class="keyword">class</span> T&gt;
106<a name="l00017"></a><a class="code" href="namespaceirr_1_1core.html#ab594dc7075680259e758e4368cd471d1">00017</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="namespaceirr_1_1core.html#ab594dc7075680259e758e4368cd471d1" title="Sinks an element into the heap.">heapsink</a>(T*<a class="code" href="classirr_1_1core_1_1array.html" title="Self reallocating template array (like stl vector) with additional features.">array</a>, <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> element, <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> max)
107<a name="l00018"></a>00018 {
108<a name="l00019"></a>00019 <span class="keywordflow">while</span> ((element&lt;&lt;1) &lt; max) <span class="comment">// there is a left child</span>
109<a name="l00020"></a>00020 {
110<a name="l00021"></a>00021 <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> j = (element&lt;&lt;1);
111<a name="l00022"></a>00022
112<a name="l00023"></a>00023 <span class="keywordflow">if</span> (j+1 &lt; max &amp;&amp; array[j] &lt; array[j+1])
113<a name="l00024"></a>00024 j = j+1; <span class="comment">// take right child</span>
114<a name="l00025"></a>00025
115<a name="l00026"></a>00026 <span class="keywordflow">if</span> (array[element] &lt; array[j])
116<a name="l00027"></a>00027 {
117<a name="l00028"></a>00028 T t = array[j]; <span class="comment">// swap elements</span>
118<a name="l00029"></a>00029 array[j] = array[element];
119<a name="l00030"></a>00030 array[element] = t;
120<a name="l00031"></a>00031 element = j;
121<a name="l00032"></a>00032 }
122<a name="l00033"></a>00033 <span class="keywordflow">else</span>
123<a name="l00034"></a>00034 <span class="keywordflow">return</span>;
124<a name="l00035"></a>00035 }
125<a name="l00036"></a>00036 }
126<a name="l00037"></a>00037
127<a name="l00038"></a>00038
128<a name="l00040"></a>00040 <span class="keyword">template</span>&lt;<span class="keyword">class</span> T&gt;
129<a name="l00041"></a><a class="code" href="namespaceirr_1_1core.html#aee38facdb42325b97626099d72f9a872">00041</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="namespaceirr_1_1core.html#aee38facdb42325b97626099d72f9a872" title="Sorts an array with size &#39;size&#39; using heapsort.">heapsort</a>(T* array_, <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> size)
130<a name="l00042"></a>00042 {
131<a name="l00043"></a>00043 <span class="comment">// for heapsink we pretent this is not c++, where</span>
132<a name="l00044"></a>00044 <span class="comment">// arrays start with index 0. So we decrease the array pointer,</span>
133<a name="l00045"></a>00045 <span class="comment">// the maximum always +2 and the element always +1</span>
134<a name="l00046"></a>00046
135<a name="l00047"></a>00047 T* virtualArray = array_ - 1;
136<a name="l00048"></a>00048 <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> virtualSize = size + 2;
137<a name="l00049"></a>00049 <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> i;
138<a name="l00050"></a>00050
139<a name="l00051"></a>00051 <span class="comment">// build heap</span>
140<a name="l00052"></a>00052
141<a name="l00053"></a>00053 <span class="keywordflow">for</span> (i=((size-1)/2); i&gt;=0; --i)
142<a name="l00054"></a>00054 <a class="code" href="namespaceirr_1_1core.html#ab594dc7075680259e758e4368cd471d1" title="Sinks an element into the heap.">heapsink</a>(virtualArray, i+1, virtualSize-1);
143<a name="l00055"></a>00055
144<a name="l00056"></a>00056 <span class="comment">// sort array, leave out the last element (0)</span>
145<a name="l00057"></a>00057 <span class="keywordflow">for</span> (i=size-1; i&gt;0; --i)
146<a name="l00058"></a>00058 {
147<a name="l00059"></a>00059 T t = array_[0];
148<a name="l00060"></a>00060 array_[0] = array_[i];
149<a name="l00061"></a>00061 array_[i] = t;
150<a name="l00062"></a>00062 <a class="code" href="namespaceirr_1_1core.html#ab594dc7075680259e758e4368cd471d1" title="Sinks an element into the heap.">heapsink</a>(virtualArray, 1, i + 1);
151<a name="l00063"></a>00063 }
152<a name="l00064"></a>00064 }
153<a name="l00065"></a>00065
154<a name="l00066"></a>00066 } <span class="comment">// end namespace core</span>
155<a name="l00067"></a>00067 } <span class="comment">// end namespace irr</span>
156<a name="l00068"></a>00068
157<a name="l00069"></a>00069 <span class="preprocessor">#endif</span>
158<a name="l00070"></a>00070 <span class="preprocessor"></span>
159</pre></div></div>
160</div>
161 <div id="nav-path" class="navpath">
162 <ul>
163 <li class="navelem"><a class="el" href="heapsort_8h.html">heapsort.h</a> </li>
164<!-- window showing the filter options -->
165<div id="MSearchSelectWindow"
166 onmouseover="return searchBox.OnSearchSelectShow()"
167 onmouseout="return searchBox.OnSearchSelectHide()"
168 onkeydown="return searchBox.OnSearchSelectKey(event)">
169<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(9)"><span class="SelectionMark">&#160;</span>Friends</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(10)"><span class="SelectionMark">&#160;</span>Defines</a></div>
170
171<!-- iframe showing the search results (closed by default) -->
172<div id="MSearchResultsWindow">
173<iframe src="javascript:void(0)" frameborder="0"
174 name="MSearchResults" id="MSearchResults">
175</iframe>
176</div>
177
178
179 <li class="footer">
180<a href="http://irrlicht.sourceforge.net" target="_blank">Irrlicht
181Engine</a> Documentation &copy; 2003-2012 by Nikolaus Gebhardt. Generated on Sun Nov 17 2013 20:18:39 for Irrlicht 3D Engine by
182<a href="http://www.doxygen.org/index.html" target="_blank">Doxygen</a> 1.7.5.1 </li>
183 </ul>
184 </div>
185
186
187</body>
188</html>