106 lines
65 KiB
HTML
106 lines
65 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
|
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
|
|
<meta name="generator" content="Doxygen 1.8.13"/>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
|
<title>entt: src/entt/entity/sparse_set.hpp Source File</title>
|
|
<link href="tabs.css" rel="stylesheet" type="text/css"/>
|
|
<script type="text/javascript" src="jquery.js"></script>
|
|
<script type="text/javascript" src="dynsections.js"></script>
|
|
<link href="search/search.css" rel="stylesheet" type="text/css"/>
|
|
<script type="text/javascript" src="search/searchdata.js"></script>
|
|
<script type="text/javascript" src="search/search.js"></script>
|
|
<link href="doxygen.css" rel="stylesheet" type="text/css" />
|
|
</head>
|
|
<body>
|
|
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
|
|
<div id="titlearea">
|
|
<table cellspacing="0" cellpadding="0">
|
|
<tbody>
|
|
<tr style="height: 56px;">
|
|
<td id="projectalign" style="padding-left: 0.5em;">
|
|
<div id="projectname">entt
|
|
 <span id="projectnumber">2.3.0</span>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<!-- end header part -->
|
|
<!-- Generated by Doxygen 1.8.13 -->
|
|
<script type="text/javascript">
|
|
var searchBox = new SearchBox("searchBox", "search",false,'Search');
|
|
</script>
|
|
<script type="text/javascript" src="menudata.js"></script>
|
|
<script type="text/javascript" src="menu.js"></script>
|
|
<script type="text/javascript">
|
|
$(function() {
|
|
initMenu('',true,false,'search.php','Search');
|
|
$(document).ready(function() { init_search(); });
|
|
});
|
|
</script>
|
|
<div id="main-nav"></div>
|
|
<!-- window showing the filter options -->
|
|
<div id="MSearchSelectWindow"
|
|
onmouseover="return searchBox.OnSearchSelectShow()"
|
|
onmouseout="return searchBox.OnSearchSelectHide()"
|
|
onkeydown="return searchBox.OnSearchSelectKey(event)">
|
|
</div>
|
|
|
|
<!-- iframe showing the search results (closed by default) -->
|
|
<div id="MSearchResultsWindow">
|
|
<iframe src="javascript:void(0)" frameborder="0"
|
|
name="MSearchResults" id="MSearchResults">
|
|
</iframe>
|
|
</div>
|
|
|
|
<div id="nav-path" class="navpath">
|
|
<ul>
|
|
<li class="navelem"><a class="el" href="dir_68267d1309a1af8e8297ef4c3efbcdba.html">src</a></li><li class="navelem"><a class="el" href="dir_66e9674e8206a335795995fa32a03c91.html">entt</a></li><li class="navelem"><a class="el" href="dir_e3a7bb56c55e5c2286e2fe96e197d4f5.html">entity</a></li> </ul>
|
|
</div>
|
|
</div><!-- top -->
|
|
<div class="header">
|
|
<div class="headertitle">
|
|
<div class="title">sparse_set.hpp</div> </div>
|
|
</div><!--header-->
|
|
<div class="contents">
|
|
<div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno"> 1</span> <span class="preprocessor">#ifndef ENTT_ENTITY_SPARSE_SET_HPP</span></div><div class="line"><a name="l00002"></a><span class="lineno"> 2</span> <span class="preprocessor">#define ENTT_ENTITY_SPARSE_SET_HPP</span></div><div class="line"><a name="l00003"></a><span class="lineno"> 3</span> </div><div class="line"><a name="l00004"></a><span class="lineno"> 4</span> </div><div class="line"><a name="l00005"></a><span class="lineno"> 5</span> <span class="preprocessor">#include <algorithm></span></div><div class="line"><a name="l00006"></a><span class="lineno"> 6</span> <span class="preprocessor">#include <numeric></span></div><div class="line"><a name="l00007"></a><span class="lineno"> 7</span> <span class="preprocessor">#include <utility></span></div><div class="line"><a name="l00008"></a><span class="lineno"> 8</span> <span class="preprocessor">#include <vector></span></div><div class="line"><a name="l00009"></a><span class="lineno"> 9</span> <span class="preprocessor">#include <cstddef></span></div><div class="line"><a name="l00010"></a><span class="lineno"> 10</span> <span class="preprocessor">#include <cassert></span></div><div class="line"><a name="l00011"></a><span class="lineno"> 11</span> <span class="preprocessor">#include <type_traits></span></div><div class="line"><a name="l00012"></a><span class="lineno"> 12</span> <span class="preprocessor">#include "traits.hpp"</span></div><div class="line"><a name="l00013"></a><span class="lineno"> 13</span> </div><div class="line"><a name="l00014"></a><span class="lineno"> 14</span> </div><div class="line"><a name="l00015"></a><span class="lineno"> 15</span> <span class="keyword">namespace </span><a class="code" href="namespaceentt.html">entt</a> {</div><div class="line"><a name="l00016"></a><span class="lineno"> 16</span> </div><div class="line"><a name="l00017"></a><span class="lineno"> 17</span> </div><div class="line"><a name="l00024"></a><span class="lineno"> 24</span> <span class="keyword">template</span><<span class="keyword">typename</span>...></div><div class="line"><a name="l00025"></a><span class="lineno"><a class="line" href="classentt_1_1SparseSet.html"> 25</a></span> <span class="keyword">class </span><a class="code" href="classentt_1_1SparseSet.html">SparseSet</a>;</div><div class="line"><a name="l00026"></a><span class="lineno"> 26</span> </div><div class="line"><a name="l00027"></a><span class="lineno"> 27</span> </div><div class="line"><a name="l00055"></a><span class="lineno"> 55</span> <span class="keyword">template</span><<span class="keyword">typename</span> Entity></div><div class="line"><a name="l00056"></a><span class="lineno"><a class="line" href="classentt_1_1SparseSet_3_01Entity_01_4.html"> 56</a></span> <span class="keyword">class </span><a class="code" href="classentt_1_1SparseSet_3_01Entity_01_4.html">SparseSet<Entity></a> {</div><div class="line"><a name="l00057"></a><span class="lineno"> 57</span>  <span class="keyword">using</span> <a class="code" href="structentt_1_1entt__traits.html">traits_type</a> = <a class="code" href="structentt_1_1entt__traits.html">entt_traits<Entity></a>;</div><div class="line"><a name="l00058"></a><span class="lineno"> 58</span> </div><div class="line"><a name="l00059"></a><span class="lineno"> 59</span>  <span class="keyword">struct </span>Iterator {</div><div class="line"><a name="l00060"></a><span class="lineno"> 60</span>  <span class="keyword">using</span> value_type = Entity;</div><div class="line"><a name="l00061"></a><span class="lineno"> 61</span> </div><div class="line"><a name="l00062"></a><span class="lineno"> 62</span>  Iterator(<span class="keyword">const</span> std::vector<Entity> *direct, std::size_t pos)</div><div class="line"><a name="l00063"></a><span class="lineno"> 63</span>  : direct{direct}, pos{pos}</div><div class="line"><a name="l00064"></a><span class="lineno"> 64</span>  {}</div><div class="line"><a name="l00065"></a><span class="lineno"> 65</span> </div><div class="line"><a name="l00066"></a><span class="lineno"> 66</span>  Iterator & operator++() noexcept {</div><div class="line"><a name="l00067"></a><span class="lineno"> 67</span>  <span class="keywordflow">return</span> --pos, *<span class="keyword">this</span>;</div><div class="line"><a name="l00068"></a><span class="lineno"> 68</span>  }</div><div class="line"><a name="l00069"></a><span class="lineno"> 69</span> </div><div class="line"><a name="l00070"></a><span class="lineno"> 70</span>  Iterator operator++(<span class="keywordtype">int</span>) noexcept {</div><div class="line"><a name="l00071"></a><span class="lineno"> 71</span>  Iterator orig = *<span class="keyword">this</span>;</div><div class="line"><a name="l00072"></a><span class="lineno"> 72</span>  <span class="keywordflow">return</span> ++(*this), orig;</div><div class="line"><a name="l00073"></a><span class="lineno"> 73</span>  }</div><div class="line"><a name="l00074"></a><span class="lineno"> 74</span> </div><div class="line"><a name="l00075"></a><span class="lineno"> 75</span>  <span class="keywordtype">bool</span> operator==(<span class="keyword">const</span> Iterator &other) <span class="keyword">const</span> noexcept {</div><div class="line"><a name="l00076"></a><span class="lineno"> 76</span>  <span class="keywordflow">return</span> other.pos == pos && other.direct == direct;</div><div class="line"><a name="l00077"></a><span class="lineno"> 77</span>  }</div><div class="line"><a name="l00078"></a><span class="lineno"> 78</span> </div><div class="line"><a name="l00079"></a><span class="lineno"> 79</span>  <span class="keywordtype">bool</span> <a class="code" href="namespaceentt.html#a18e1a7cdfcb0c0ba075e0beeda95285f">operator!=</a>(<span class="keyword">const</span> Iterator &other) <span class="keyword">const</span> noexcept {</div><div class="line"><a name="l00080"></a><span class="lineno"> 80</span>  <span class="keywordflow">return</span> !(*<span class="keyword">this</span> == other);</div><div class="line"><a name="l00081"></a><span class="lineno"> 81</span>  }</div><div class="line"><a name="l00082"></a><span class="lineno"> 82</span> </div><div class="line"><a name="l00083"></a><span class="lineno"> 83</span>  value_type operator*() <span class="keyword">const</span> noexcept {</div><div class="line"><a name="l00084"></a><span class="lineno"> 84</span>  <span class="keywordflow">return</span> (*direct)[pos-1];</div><div class="line"><a name="l00085"></a><span class="lineno"> 85</span>  }</div><div class="line"><a name="l00086"></a><span class="lineno"> 86</span> </div><div class="line"><a name="l00087"></a><span class="lineno"> 87</span>  <span class="keyword">private</span>:</div><div class="line"><a name="l00088"></a><span class="lineno"> 88</span>  <span class="keyword">const</span> std::vector<Entity> *direct;</div><div class="line"><a name="l00089"></a><span class="lineno"> 89</span>  std::size_t pos;</div><div class="line"><a name="l00090"></a><span class="lineno"> 90</span>  };</div><div class="line"><a name="l00091"></a><span class="lineno"> 91</span> </div><div class="line"><a name="l00092"></a><span class="lineno"> 92</span>  <span class="keyword">static</span> constexpr Entity in_use = (Entity{1} << traits_type::entity_shift);</div><div class="line"><a name="l00093"></a><span class="lineno"> 93</span> </div><div class="line"><a name="l00094"></a><span class="lineno"> 94</span> <span class="keyword">public</span>:</div><div class="line"><a name="l00096"></a><span class="lineno"><a class="line" href="classentt_1_1SparseSet_3_01Entity_01_4.html#a7d36e852257a965a9a0ed3fb636433e2"> 96</a></span>  <span class="keyword">using</span> <a class="code" href="classentt_1_1SparseSet_3_01Entity_01_4.html#a7d36e852257a965a9a0ed3fb636433e2">entity_type</a> = Entity;</div><div class="line"><a name="l00098"></a><span class="lineno"><a class="line" href="classentt_1_1SparseSet_3_01Entity_01_4.html#a20c218a69cf339371251ffa5580d7aa0"> 98</a></span>  <span class="keyword">using</span> <a class="code" href="classentt_1_1SparseSet_3_01Entity_01_4.html#a20c218a69cf339371251ffa5580d7aa0">pos_type</a> = <a class="code" href="classentt_1_1SparseSet_3_01Entity_01_4.html#a7d36e852257a965a9a0ed3fb636433e2">entity_type</a>;</div><div class="line"><a name="l00100"></a><span class="lineno"><a class="line" href="classentt_1_1SparseSet_3_01Entity_01_4.html#ab81c48dcee7a1104ee82794613ee7ed2"> 100</a></span>  <span class="keyword">using</span> <a class="code" href="classentt_1_1SparseSet_3_01Entity_01_4.html#ab81c48dcee7a1104ee82794613ee7ed2">size_type</a> = std::size_t;</div><div class="line"><a name="l00102"></a><span class="lineno"><a class="line" href="classentt_1_1SparseSet_3_01Entity_01_4.html#a1ad77aed1e49af60b61044c996969b9a"> 102</a></span>  <span class="keyword">using</span> <a class="code" href="classentt_1_1SparseSet_3_01Entity_01_4.html#a1ad77aed1e49af60b61044c996969b9a">iterator_type</a> = Iterator;</div><div class="line"><a name="l00103"></a><span class="lineno"> 103</span> </div><div class="line"><a name="l00105"></a><span class="lineno"> 105</span>  <a class="code" href="classentt_1_1SparseSet.html">SparseSet</a>() noexcept = default;</div><div class="line"><a name="l00106"></a><span class="lineno"> 106</span> </div><div class="line"><a name="l00108"></a><span class="lineno"> 108</span>  virtual ~<a class="code" href="classentt_1_1SparseSet.html">SparseSet</a>() noexcept = default;</div><div class="line"><a name="l00109"></a><span class="lineno"> 109</span> </div><div class="line"><a name="l00111"></a><span class="lineno"> 111</span>  <a class="code" href="classentt_1_1SparseSet.html">SparseSet</a>(const <a class="code" href="classentt_1_1SparseSet.html">SparseSet</a> &) = delete;</div><div class="line"><a name="l00113"></a><span class="lineno"> 113</span>  <a class="code" href="classentt_1_1SparseSet.html">SparseSet</a>(<a class="code" href="classentt_1_1SparseSet.html">SparseSet</a> &&) = default;</div><div class="line"><a name="l00114"></a><span class="lineno"> 114</span> </div><div class="line"><a name="l00116"></a><span class="lineno"> 116</span>  <a class="code" href="classentt_1_1SparseSet.html">SparseSet</a> & operator=(const <a class="code" href="classentt_1_1SparseSet.html">SparseSet</a> &) = delete;</div><div class="line"><a name="l00118"></a><span class="lineno"> 118</span>  <a class="code" href="classentt_1_1SparseSet.html">SparseSet</a> & operator=(<a class="code" href="classentt_1_1SparseSet.html">SparseSet</a> &&) = default;</div><div class="line"><a name="l00119"></a><span class="lineno"> 119</span> </div><div class="line"><a name="l00130"></a><span class="lineno"><a class="line" href="classentt_1_1SparseSet_3_01Entity_01_4.html#a337360e8d0f44c373acef65328a3e9f8"> 130</a></span>  <a class="code" href="classentt_1_1SparseSet_3_01Entity_01_4.html#ab81c48dcee7a1104ee82794613ee7ed2">size_type</a> size() const noexcept {</div><div class="line"><a name="l00131"></a><span class="lineno"> 131</span>  <span class="keywordflow">return</span> direct.size();</div><div class="line"><a name="l00132"></a><span class="lineno"> 132</span>  }</div><div class="line"><a name="l00133"></a><span class="lineno"> 133</span> </div><div class="line"><a name="l00138"></a><span class="lineno"><a class="line" href="classentt_1_1SparseSet_3_01Entity_01_4.html#a9d6b9c98d2645d821c81ff7d3586ca27"> 138</a></span>  <span class="keywordtype">bool</span> <a class="code" href="classentt_1_1SparseSet_3_01Entity_01_4.html#a9d6b9c98d2645d821c81ff7d3586ca27">empty</a>() const noexcept {</div><div class="line"><a name="l00139"></a><span class="lineno"> 139</span>  <span class="keywordflow">return</span> direct.empty();</div><div class="line"><a name="l00140"></a><span class="lineno"> 140</span>  }</div><div class="line"><a name="l00141"></a><span class="lineno"> 141</span> </div><div class="line"><a name="l00157"></a><span class="lineno"><a class="line" href="classentt_1_1SparseSet_3_01Entity_01_4.html#a6e4dda542e3d725dd963dea57bfb9cb1"> 157</a></span>  <span class="keyword">const</span> <a class="code" href="classentt_1_1SparseSet_3_01Entity_01_4.html#a7d36e852257a965a9a0ed3fb636433e2">entity_type</a> * <a class="code" href="classentt_1_1SparseSet_3_01Entity_01_4.html#a6e4dda542e3d725dd963dea57bfb9cb1">data</a>() const noexcept {</div><div class="line"><a name="l00158"></a><span class="lineno"> 158</span>  <span class="keywordflow">return</span> direct.data();</div><div class="line"><a name="l00159"></a><span class="lineno"> 159</span>  }</div><div class="line"><a name="l00160"></a><span class="lineno"> 160</span> </div><div class="line"><a name="l00173"></a><span class="lineno"><a class="line" href="classentt_1_1SparseSet_3_01Entity_01_4.html#a1efc9899f2ede4fd8ea1840a7ed8dbc7"> 173</a></span>  <a class="code" href="classentt_1_1SparseSet_3_01Entity_01_4.html#a1ad77aed1e49af60b61044c996969b9a">iterator_type</a> <a class="code" href="classentt_1_1SparseSet_3_01Entity_01_4.html#a1efc9899f2ede4fd8ea1840a7ed8dbc7">begin</a>() const noexcept {</div><div class="line"><a name="l00174"></a><span class="lineno"> 174</span>  <span class="keywordflow">return</span> Iterator{&direct, direct.size()};</div><div class="line"><a name="l00175"></a><span class="lineno"> 175</span>  }</div><div class="line"><a name="l00176"></a><span class="lineno"> 176</span> </div><div class="line"><a name="l00190"></a><span class="lineno"><a class="line" href="classentt_1_1SparseSet_3_01Entity_01_4.html#a2c54395d55054437bfe179718e102181"> 190</a></span>  <a class="code" href="classentt_1_1SparseSet_3_01Entity_01_4.html#a1ad77aed1e49af60b61044c996969b9a">iterator_type</a> <a class="code" href="classentt_1_1SparseSet_3_01Entity_01_4.html#a2c54395d55054437bfe179718e102181">end</a>() const noexcept {</div><div class="line"><a name="l00191"></a><span class="lineno"> 191</span>  <span class="keywordflow">return</span> Iterator{&direct, 0};</div><div class="line"><a name="l00192"></a><span class="lineno"> 192</span>  }</div><div class="line"><a name="l00193"></a><span class="lineno"> 193</span> </div><div class="line"><a name="l00199"></a><span class="lineno"><a class="line" href="classentt_1_1SparseSet_3_01Entity_01_4.html#a1b6a33e6e65345bf028877efa74c5a5e"> 199</a></span>  <span class="keywordtype">bool</span> <a class="code" href="classentt_1_1SparseSet_3_01Entity_01_4.html#a1b6a33e6e65345bf028877efa74c5a5e">has</a>(<a class="code" href="classentt_1_1SparseSet_3_01Entity_01_4.html#a7d36e852257a965a9a0ed3fb636433e2">entity_type</a> entity) <span class="keyword">const</span> noexcept {</div><div class="line"><a name="l00200"></a><span class="lineno"> 200</span>  <span class="keyword">using</span> promotion_type = std::conditional_t<sizeof(size_type) >= <span class="keyword">sizeof</span>(<a class="code" href="classentt_1_1SparseSet_3_01Entity_01_4.html#a7d36e852257a965a9a0ed3fb636433e2">entity_type</a>), <a class="code" href="classentt_1_1SparseSet_3_01Entity_01_4.html#ab81c48dcee7a1104ee82794613ee7ed2">size_type</a>, <a class="code" href="classentt_1_1SparseSet_3_01Entity_01_4.html#a7d36e852257a965a9a0ed3fb636433e2">entity_type</a>>;</div><div class="line"><a name="l00201"></a><span class="lineno"> 201</span>  <span class="comment">// explicit promotion to avoid warnings with std::uint16_t</span></div><div class="line"><a name="l00202"></a><span class="lineno"> 202</span>  <span class="keyword">const</span> <span class="keyword">auto</span> <a class="code" href="namespaceentt.html">entt</a> = promotion_type{entity} & traits_type::entity_mask;</div><div class="line"><a name="l00203"></a><span class="lineno"> 203</span>  <span class="comment">// the in-use control bit permits to avoid accessing the direct vector</span></div><div class="line"><a name="l00204"></a><span class="lineno"> 204</span>  <span class="keywordflow">return</span> (<a class="code" href="namespaceentt.html">entt</a> < reverse.size()) && (reverse[<a class="code" href="namespaceentt.html">entt</a>] & in_use);</div><div class="line"><a name="l00205"></a><span class="lineno"> 205</span>  }</div><div class="line"><a name="l00206"></a><span class="lineno"> 206</span> </div><div class="line"><a name="l00219"></a><span class="lineno"><a class="line" href="classentt_1_1SparseSet_3_01Entity_01_4.html#a7aa0a2c4f286228fc47d32761552bc13"> 219</a></span>  <a class="code" href="classentt_1_1SparseSet_3_01Entity_01_4.html#a20c218a69cf339371251ffa5580d7aa0">pos_type</a> <span class="keyword">get</span>(<a class="code" href="classentt_1_1SparseSet_3_01Entity_01_4.html#a7d36e852257a965a9a0ed3fb636433e2">entity_type</a> entity) <span class="keyword">const</span> noexcept {</div><div class="line"><a name="l00220"></a><span class="lineno"> 220</span>  assert(has(entity));</div><div class="line"><a name="l00221"></a><span class="lineno"> 221</span>  <span class="keyword">const</span> <span class="keyword">auto</span> <a class="code" href="namespaceentt.html">entt</a> = entity & traits_type::entity_mask;</div><div class="line"><a name="l00222"></a><span class="lineno"> 222</span>  <span class="comment">// we must get rid of the in-use bit for it's not part of the position</span></div><div class="line"><a name="l00223"></a><span class="lineno"> 223</span>  <span class="keywordflow">return</span> reverse[<a class="code" href="namespaceentt.html">entt</a>] & ~in_use;</div><div class="line"><a name="l00224"></a><span class="lineno"> 224</span>  }</div><div class="line"><a name="l00225"></a><span class="lineno"> 225</span> </div><div class="line"><a name="l00237"></a><span class="lineno"><a class="line" href="classentt_1_1SparseSet_3_01Entity_01_4.html#adb65da9a09f41dcf6ec433066a7891c3"> 237</a></span>  <span class="keywordtype">void</span> <a class="code" href="classentt_1_1SparseSet_3_01Entity_01_4.html#adb65da9a09f41dcf6ec433066a7891c3">construct</a>(<a class="code" href="classentt_1_1SparseSet_3_01Entity_01_4.html#a7d36e852257a965a9a0ed3fb636433e2">entity_type</a> entity) {</div><div class="line"><a name="l00238"></a><span class="lineno"> 238</span>  assert(!has(entity));</div><div class="line"><a name="l00239"></a><span class="lineno"> 239</span>  <span class="keyword">using</span> promotion_type = std::conditional_t<sizeof(size_type) >= <span class="keyword">sizeof</span>(<a class="code" href="classentt_1_1SparseSet_3_01Entity_01_4.html#a7d36e852257a965a9a0ed3fb636433e2">entity_type</a>), <a class="code" href="classentt_1_1SparseSet_3_01Entity_01_4.html#ab81c48dcee7a1104ee82794613ee7ed2">size_type</a>, <a class="code" href="classentt_1_1SparseSet_3_01Entity_01_4.html#a7d36e852257a965a9a0ed3fb636433e2">entity_type</a>>;</div><div class="line"><a name="l00240"></a><span class="lineno"> 240</span>  <span class="comment">// explicit promotion to avoid warnings with std::uint16_t</span></div><div class="line"><a name="l00241"></a><span class="lineno"> 241</span>  <span class="keyword">const</span> <span class="keyword">auto</span> <a class="code" href="namespaceentt.html">entt</a> = promotion_type{entity} & traits_type::entity_mask;</div><div class="line"><a name="l00242"></a><span class="lineno"> 242</span> </div><div class="line"><a name="l00243"></a><span class="lineno"> 243</span>  <span class="keywordflow">if</span>(!(<a class="code" href="namespaceentt.html">entt</a> < reverse.size())) {</div><div class="line"><a name="l00244"></a><span class="lineno"> 244</span>  reverse.resize(<a class="code" href="namespaceentt.html">entt</a>+1, <a class="code" href="classentt_1_1SparseSet_3_01Entity_01_4.html#a20c218a69cf339371251ffa5580d7aa0">pos_type</a>{});</div><div class="line"><a name="l00245"></a><span class="lineno"> 245</span>  }</div><div class="line"><a name="l00246"></a><span class="lineno"> 246</span> </div><div class="line"><a name="l00247"></a><span class="lineno"> 247</span>  <span class="comment">// we exploit the fact that pos_type is equal to entity_type and pos has</span></div><div class="line"><a name="l00248"></a><span class="lineno"> 248</span>  <span class="comment">// traits_type::version_mask bits unused we can use to mark it as in-use</span></div><div class="line"><a name="l00249"></a><span class="lineno"> 249</span>  reverse[<a class="code" href="namespaceentt.html">entt</a>] = <a class="code" href="classentt_1_1SparseSet_3_01Entity_01_4.html#a20c218a69cf339371251ffa5580d7aa0">pos_type</a>(direct.size()) | in_use;</div><div class="line"><a name="l00250"></a><span class="lineno"> 250</span>  direct.emplace_back(entity);</div><div class="line"><a name="l00251"></a><span class="lineno"> 251</span>  }</div><div class="line"><a name="l00252"></a><span class="lineno"> 252</span> </div><div class="line"><a name="l00264"></a><span class="lineno"><a class="line" href="classentt_1_1SparseSet_3_01Entity_01_4.html#ab4be1be8435da50621373c0bd737a1e8"> 264</a></span>  <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classentt_1_1SparseSet_3_01Entity_01_4.html#ab4be1be8435da50621373c0bd737a1e8">destroy</a>(<a class="code" href="classentt_1_1SparseSet_3_01Entity_01_4.html#a7d36e852257a965a9a0ed3fb636433e2">entity_type</a> entity) {</div><div class="line"><a name="l00265"></a><span class="lineno"> 265</span>  assert(has(entity));</div><div class="line"><a name="l00266"></a><span class="lineno"> 266</span>  <span class="keyword">const</span> <span class="keyword">auto</span> <a class="code" href="namespaceentt.html">entt</a> = entity & traits_type::entity_mask;</div><div class="line"><a name="l00267"></a><span class="lineno"> 267</span>  <span class="keyword">const</span> <span class="keyword">auto</span> back = direct.back() & traits_type::entity_mask;</div><div class="line"><a name="l00268"></a><span class="lineno"> 268</span>  <span class="keyword">const</span> <span class="keyword">auto</span> pos = reverse[<a class="code" href="namespaceentt.html">entt</a>] & ~in_use;</div><div class="line"><a name="l00269"></a><span class="lineno"> 269</span>  <span class="comment">// the order matters: if back and entt are the same (for the sparse set</span></div><div class="line"><a name="l00270"></a><span class="lineno"> 270</span>  <span class="comment">// has size 1), switching the two lines below doesn't work as expected</span></div><div class="line"><a name="l00271"></a><span class="lineno"> 271</span>  reverse[back] = pos | in_use;</div><div class="line"><a name="l00272"></a><span class="lineno"> 272</span>  reverse[<a class="code" href="namespaceentt.html">entt</a>] = pos;</div><div class="line"><a name="l00273"></a><span class="lineno"> 273</span>  <span class="comment">// swapping isn't required here, we are getting rid of the last element</span></div><div class="line"><a name="l00274"></a><span class="lineno"> 274</span>  direct[pos] = direct.back();</div><div class="line"><a name="l00275"></a><span class="lineno"> 275</span>  direct.pop_back();</div><div class="line"><a name="l00276"></a><span class="lineno"> 276</span>  }</div><div class="line"><a name="l00277"></a><span class="lineno"> 277</span> </div><div class="line"><a name="l00293"></a><span class="lineno"><a class="line" href="classentt_1_1SparseSet_3_01Entity_01_4.html#af122c1668ab1efbe0eca5792e9bae434"> 293</a></span>  <span class="keywordtype">void</span> <a class="code" href="classentt_1_1SparseSet_3_01Entity_01_4.html#af122c1668ab1efbe0eca5792e9bae434">swap</a>(<a class="code" href="classentt_1_1SparseSet_3_01Entity_01_4.html#a20c218a69cf339371251ffa5580d7aa0">pos_type</a> lhs, <a class="code" href="classentt_1_1SparseSet_3_01Entity_01_4.html#a20c218a69cf339371251ffa5580d7aa0">pos_type</a> rhs) noexcept {</div><div class="line"><a name="l00294"></a><span class="lineno"> 294</span>  assert(lhs < direct.size());</div><div class="line"><a name="l00295"></a><span class="lineno"> 295</span>  assert(rhs < direct.size());</div><div class="line"><a name="l00296"></a><span class="lineno"> 296</span>  std::swap(reverse[direct[lhs]], reverse[direct[rhs]]);</div><div class="line"><a name="l00297"></a><span class="lineno"> 297</span>  std::swap(direct[lhs], direct[rhs]);</div><div class="line"><a name="l00298"></a><span class="lineno"> 298</span>  }</div><div class="line"><a name="l00299"></a><span class="lineno"> 299</span> </div><div class="line"><a name="l00319"></a><span class="lineno"><a class="line" href="classentt_1_1SparseSet_3_01Entity_01_4.html#a7a6ff2340d8accf14bdaa83676cbc670"> 319</a></span>  <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classentt_1_1SparseSet_3_01Entity_01_4.html#a7a6ff2340d8accf14bdaa83676cbc670">respect</a>(<span class="keyword">const</span> <a class="code" href="classentt_1_1SparseSet_3_01Entity_01_4.html">SparseSet<Entity></a> &other) noexcept {</div><div class="line"><a name="l00320"></a><span class="lineno"> 320</span>  <span class="keyword">auto</span> from = other.begin();</div><div class="line"><a name="l00321"></a><span class="lineno"> 321</span>  <span class="keyword">auto</span> to = other.end();</div><div class="line"><a name="l00322"></a><span class="lineno"> 322</span> </div><div class="line"><a name="l00323"></a><span class="lineno"> 323</span>  <a class="code" href="classentt_1_1SparseSet_3_01Entity_01_4.html#a20c218a69cf339371251ffa5580d7aa0">pos_type</a> pos = direct.size() - 1;</div><div class="line"><a name="l00324"></a><span class="lineno"> 324</span> </div><div class="line"><a name="l00325"></a><span class="lineno"> 325</span>  <span class="keywordflow">while</span>(pos > 0 && from != to) {</div><div class="line"><a name="l00326"></a><span class="lineno"> 326</span>  <span class="keywordflow">if</span>(has(*from)) {</div><div class="line"><a name="l00327"></a><span class="lineno"> 327</span>  <span class="keywordflow">if</span>(*from != direct[pos]) {</div><div class="line"><a name="l00328"></a><span class="lineno"> 328</span>  swap(pos, <span class="keyword">get</span>(*from));</div><div class="line"><a name="l00329"></a><span class="lineno"> 329</span>  }</div><div class="line"><a name="l00330"></a><span class="lineno"> 330</span> </div><div class="line"><a name="l00331"></a><span class="lineno"> 331</span>  --pos;</div><div class="line"><a name="l00332"></a><span class="lineno"> 332</span>  }</div><div class="line"><a name="l00333"></a><span class="lineno"> 333</span> </div><div class="line"><a name="l00334"></a><span class="lineno"> 334</span>  ++from;</div><div class="line"><a name="l00335"></a><span class="lineno"> 335</span>  }</div><div class="line"><a name="l00336"></a><span class="lineno"> 336</span>  }</div><div class="line"><a name="l00337"></a><span class="lineno"> 337</span> </div><div class="line"><a name="l00341"></a><span class="lineno"><a class="line" href="classentt_1_1SparseSet_3_01Entity_01_4.html#ad1c62c65aeb0112e688f05d8f641cdab"> 341</a></span>  <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classentt_1_1SparseSet_3_01Entity_01_4.html#ad1c62c65aeb0112e688f05d8f641cdab">reset</a>() {</div><div class="line"><a name="l00342"></a><span class="lineno"> 342</span>  reverse.clear();</div><div class="line"><a name="l00343"></a><span class="lineno"> 343</span>  direct.clear();</div><div class="line"><a name="l00344"></a><span class="lineno"> 344</span>  }</div><div class="line"><a name="l00345"></a><span class="lineno"> 345</span> </div><div class="line"><a name="l00346"></a><span class="lineno"> 346</span> <span class="keyword">private</span>:</div><div class="line"><a name="l00347"></a><span class="lineno"> 347</span>  std::vector<pos_type> reverse;</div><div class="line"><a name="l00348"></a><span class="lineno"> 348</span>  std::vector<entity_type> direct;</div><div class="line"><a name="l00349"></a><span class="lineno"> 349</span> };</div><div class="line"><a name="l00350"></a><span class="lineno"> 350</span> </div><div class="line"><a name="l00351"></a><span class="lineno"> 351</span> </div><div class="line"><a name="l00374"></a><span class="lineno"> 374</span> <span class="keyword">template</span><<span class="keyword">typename</span> Entity, <span class="keyword">typename</span> Type></div><div class="line"><a name="l00375"></a><span class="lineno"><a class="line" href="classentt_1_1SparseSet_3_01Entity_00_01Type_01_4.html"> 375</a></span> <span class="keyword">class </span><a class="code" href="classentt_1_1SparseSet_3_01Entity_00_01Type_01_4.html">SparseSet<Entity, Type></a>: <span class="keyword">public</span> <a class="code" href="classentt_1_1SparseSet_3_01Entity_01_4.html">SparseSet<Entity></a> {</div><div class="line"><a name="l00376"></a><span class="lineno"> 376</span>  <span class="keyword">using</span> <a class="code" href="classentt_1_1SparseSet_3_01Entity_01_4.html">underlying_type</a> = <a class="code" href="classentt_1_1SparseSet_3_01Entity_01_4.html">SparseSet<Entity></a>;</div><div class="line"><a name="l00377"></a><span class="lineno"> 377</span> </div><div class="line"><a name="l00378"></a><span class="lineno"> 378</span> <span class="keyword">public</span>:</div><div class="line"><a name="l00380"></a><span class="lineno"><a class="line" href="classentt_1_1SparseSet_3_01Entity_00_01Type_01_4.html#af7db79dfb4e031a63fa526d4f7d54915"> 380</a></span>  <span class="keyword">using</span> <a class="code" href="classentt_1_1SparseSet_3_01Entity_00_01Type_01_4.html#af7db79dfb4e031a63fa526d4f7d54915">object_type</a> = Type;</div><div class="line"><a name="l00382"></a><span class="lineno"><a class="line" href="classentt_1_1SparseSet_3_01Entity_00_01Type_01_4.html#afe382e2d5c8769fb3d924e1a357cf9b0"> 382</a></span>  <span class="keyword">using</span> <a class="code" href="classentt_1_1SparseSet_3_01Entity_01_4.html#a7d36e852257a965a9a0ed3fb636433e2">entity_type</a> = <span class="keyword">typename</span> <a class="code" href="classentt_1_1SparseSet_3_01Entity_01_4.html#a7d36e852257a965a9a0ed3fb636433e2">underlying_type::entity_type</a>;</div><div class="line"><a name="l00384"></a><span class="lineno"><a class="line" href="classentt_1_1SparseSet_3_01Entity_00_01Type_01_4.html#ad161a395ca3979154a333520662c7737"> 384</a></span>  <span class="keyword">using</span> <a class="code" href="classentt_1_1SparseSet_3_01Entity_01_4.html#a20c218a69cf339371251ffa5580d7aa0">pos_type</a> = <span class="keyword">typename</span> <a class="code" href="classentt_1_1SparseSet_3_01Entity_01_4.html#a20c218a69cf339371251ffa5580d7aa0">underlying_type::pos_type</a>;</div><div class="line"><a name="l00386"></a><span class="lineno"><a class="line" href="classentt_1_1SparseSet_3_01Entity_00_01Type_01_4.html#a27a88e2bb0822de41131741d9ffcded5"> 386</a></span>  <span class="keyword">using</span> <a class="code" href="classentt_1_1SparseSet_3_01Entity_01_4.html#ab81c48dcee7a1104ee82794613ee7ed2">size_type</a> = <span class="keyword">typename</span> <a class="code" href="classentt_1_1SparseSet_3_01Entity_01_4.html#ab81c48dcee7a1104ee82794613ee7ed2">underlying_type::size_type</a>;</div><div class="line"><a name="l00388"></a><span class="lineno"><a class="line" href="classentt_1_1SparseSet_3_01Entity_00_01Type_01_4.html#aab1937b624841a57dd7487e7a40ea0ac"> 388</a></span>  <span class="keyword">using</span> <a class="code" href="classentt_1_1SparseSet_3_01Entity_01_4.html#a1ad77aed1e49af60b61044c996969b9a">iterator_type</a> = <span class="keyword">typename</span> <a class="code" href="classentt_1_1SparseSet_3_01Entity_01_4.html#a1ad77aed1e49af60b61044c996969b9a">underlying_type::iterator_type</a>;</div><div class="line"><a name="l00389"></a><span class="lineno"> 389</span> </div><div class="line"><a name="l00391"></a><span class="lineno"> 391</span>  <a class="code" href="classentt_1_1SparseSet.html">SparseSet</a>() noexcept = default;</div><div class="line"><a name="l00392"></a><span class="lineno"> 392</span> </div><div class="line"><a name="l00394"></a><span class="lineno"> 394</span>  <a class="code" href="classentt_1_1SparseSet.html">SparseSet</a>(const <a class="code" href="classentt_1_1SparseSet.html">SparseSet</a> &) = delete;</div><div class="line"><a name="l00396"></a><span class="lineno"> 396</span>  <a class="code" href="classentt_1_1SparseSet.html">SparseSet</a>(<a class="code" href="classentt_1_1SparseSet.html">SparseSet</a> &&) = default;</div><div class="line"><a name="l00397"></a><span class="lineno"> 397</span> </div><div class="line"><a name="l00399"></a><span class="lineno"> 399</span>  <a class="code" href="classentt_1_1SparseSet.html">SparseSet</a> & operator=(const <a class="code" href="classentt_1_1SparseSet.html">SparseSet</a> &) = delete;</div><div class="line"><a name="l00401"></a><span class="lineno"> 401</span>  <a class="code" href="classentt_1_1SparseSet.html">SparseSet</a> & operator=(<a class="code" href="classentt_1_1SparseSet.html">SparseSet</a> &&) = default;</div><div class="line"><a name="l00402"></a><span class="lineno"> 402</span> </div><div class="line"><a name="l00418"></a><span class="lineno"><a class="line" href="classentt_1_1SparseSet_3_01Entity_00_01Type_01_4.html#aafa311b5b7379150782d94dffdbab959"> 418</a></span>  const <a class="code" href="classentt_1_1SparseSet_3_01Entity_00_01Type_01_4.html#af7db79dfb4e031a63fa526d4f7d54915">object_type</a> * raw() const noexcept {</div><div class="line"><a name="l00419"></a><span class="lineno"> 419</span>  <span class="keywordflow">return</span> instances.data();</div><div class="line"><a name="l00420"></a><span class="lineno"> 420</span>  }</div><div class="line"><a name="l00421"></a><span class="lineno"> 421</span> </div><div class="line"><a name="l00437"></a><span class="lineno"><a class="line" href="classentt_1_1SparseSet_3_01Entity_00_01Type_01_4.html#ac64be22bc7dcb2498257dccbbcfa004f"> 437</a></span>  <a class="code" href="classentt_1_1SparseSet_3_01Entity_00_01Type_01_4.html#af7db79dfb4e031a63fa526d4f7d54915">object_type</a> * <a class="code" href="classentt_1_1SparseSet_3_01Entity_00_01Type_01_4.html#ac64be22bc7dcb2498257dccbbcfa004f">raw</a>() noexcept {</div><div class="line"><a name="l00438"></a><span class="lineno"> 438</span>  <span class="keywordflow">return</span> instances.data();</div><div class="line"><a name="l00439"></a><span class="lineno"> 439</span>  }</div><div class="line"><a name="l00440"></a><span class="lineno"> 440</span> </div><div class="line"><a name="l00453"></a><span class="lineno"><a class="line" href="classentt_1_1SparseSet_3_01Entity_00_01Type_01_4.html#ad24ca11a0ce0be4775978c3a06aed24b"> 453</a></span>  <span class="keyword">const</span> <a class="code" href="classentt_1_1SparseSet_3_01Entity_00_01Type_01_4.html#af7db79dfb4e031a63fa526d4f7d54915">object_type</a> & <span class="keyword">get</span>(<a class="code" href="classentt_1_1SparseSet_3_01Entity_01_4.html#a7d36e852257a965a9a0ed3fb636433e2">entity_type</a> entity) <span class="keyword">const</span> noexcept {</div><div class="line"><a name="l00454"></a><span class="lineno"> 454</span>  <span class="keywordflow">return</span> instances[underlying_type::get(entity)];</div><div class="line"><a name="l00455"></a><span class="lineno"> 455</span>  }</div><div class="line"><a name="l00456"></a><span class="lineno"> 456</span> </div><div class="line"><a name="l00469"></a><span class="lineno"><a class="line" href="classentt_1_1SparseSet_3_01Entity_00_01Type_01_4.html#acc051a79f32ee11605c5b61d76e66ef1"> 469</a></span>  <a class="code" href="classentt_1_1SparseSet_3_01Entity_00_01Type_01_4.html#af7db79dfb4e031a63fa526d4f7d54915">object_type</a> & <span class="keyword">get</span>(<a class="code" href="classentt_1_1SparseSet_3_01Entity_01_4.html#a7d36e852257a965a9a0ed3fb636433e2">entity_type</a> entity) noexcept {</div><div class="line"><a name="l00470"></a><span class="lineno"> 470</span>  <span class="keywordflow">return</span> <span class="keyword">const_cast<</span><a class="code" href="classentt_1_1SparseSet_3_01Entity_00_01Type_01_4.html#af7db79dfb4e031a63fa526d4f7d54915">object_type</a> &<span class="keyword">></span>(<span class="keyword">const_cast<</span><span class="keyword">const </span><a class="code" href="classentt_1_1SparseSet.html">SparseSet</a> *<span class="keyword">></span>(<span class="keyword">this</span>)-><span class="keyword">get</span>(entity));</div><div class="line"><a name="l00471"></a><span class="lineno"> 471</span>  }</div><div class="line"><a name="l00472"></a><span class="lineno"> 472</span> </div><div class="line"><a name="l00487"></a><span class="lineno"> 487</span>  <span class="keyword">template</span><<span class="keyword">typename</span>... Args></div><div class="line"><a name="l00488"></a><span class="lineno"><a class="line" href="classentt_1_1SparseSet_3_01Entity_00_01Type_01_4.html#aa31e003cb882774dfb81fabb5d88e554"> 488</a></span>  <a class="code" href="classentt_1_1SparseSet_3_01Entity_00_01Type_01_4.html#af7db79dfb4e031a63fa526d4f7d54915">object_type</a> & <a class="code" href="classentt_1_1SparseSet_3_01Entity_00_01Type_01_4.html#aa31e003cb882774dfb81fabb5d88e554">construct</a>(<a class="code" href="classentt_1_1SparseSet_3_01Entity_01_4.html#a7d36e852257a965a9a0ed3fb636433e2">entity_type</a> entity, Args&&... args) {</div><div class="line"><a name="l00489"></a><span class="lineno"> 489</span>  underlying_type::construct(entity);</div><div class="line"><a name="l00490"></a><span class="lineno"> 490</span>  <span class="comment">// emplace_back doesn't work well with PODs because of its placement new</span></div><div class="line"><a name="l00491"></a><span class="lineno"> 491</span>  instances.push_back({ std::forward<Args>(args)... });</div><div class="line"><a name="l00492"></a><span class="lineno"> 492</span>  <span class="keywordflow">return</span> instances.back();</div><div class="line"><a name="l00493"></a><span class="lineno"> 493</span>  }</div><div class="line"><a name="l00494"></a><span class="lineno"> 494</span> </div><div class="line"><a name="l00506"></a><span class="lineno"><a class="line" href="classentt_1_1SparseSet_3_01Entity_00_01Type_01_4.html#a06b863abd1b457c48b7080e203b47a0f"> 506</a></span>  <span class="keywordtype">void</span> <a class="code" href="classentt_1_1SparseSet_3_01Entity_00_01Type_01_4.html#a06b863abd1b457c48b7080e203b47a0f">destroy</a>(<a class="code" href="classentt_1_1SparseSet_3_01Entity_01_4.html#a7d36e852257a965a9a0ed3fb636433e2">entity_type</a> entity)<span class="keyword"> override </span>{</div><div class="line"><a name="l00507"></a><span class="lineno"> 507</span>  <span class="comment">// swapping isn't required here, we are getting rid of the last element</span></div><div class="line"><a name="l00508"></a><span class="lineno"> 508</span>  instances[underlying_type::get(entity)] = std::move(instances.back());</div><div class="line"><a name="l00509"></a><span class="lineno"> 509</span>  instances.pop_back();</div><div class="line"><a name="l00510"></a><span class="lineno"> 510</span>  underlying_type::destroy(entity);</div><div class="line"><a name="l00511"></a><span class="lineno"> 511</span>  }</div><div class="line"><a name="l00512"></a><span class="lineno"> 512</span> </div><div class="line"><a name="l00535"></a><span class="lineno"> 535</span>  <span class="keyword">template</span><<span class="keyword">typename</span> Compare></div><div class="line"><a name="l00536"></a><span class="lineno"><a class="line" href="classentt_1_1SparseSet_3_01Entity_00_01Type_01_4.html#a91cbe1334ba5135e44dab73adedbad8d"> 536</a></span>  <span class="keywordtype">void</span> <a class="code" href="classentt_1_1SparseSet_3_01Entity_00_01Type_01_4.html#a91cbe1334ba5135e44dab73adedbad8d">sort</a>(Compare compare) {</div><div class="line"><a name="l00537"></a><span class="lineno"> 537</span>  std::vector<pos_type> copy(instances.size());</div><div class="line"><a name="l00538"></a><span class="lineno"> 538</span>  std::iota(copy.begin(), copy.end(), 0);</div><div class="line"><a name="l00539"></a><span class="lineno"> 539</span> </div><div class="line"><a name="l00540"></a><span class="lineno"> 540</span>  std::sort(copy.begin(), copy.end(), [<span class="keyword">this</span>, compare = std::move(compare)](<span class="keyword">auto</span> lhs, <span class="keyword">auto</span> rhs) {</div><div class="line"><a name="l00541"></a><span class="lineno"> 541</span>  <span class="keywordflow">return</span> compare(const_cast<const object_type &>(instances[rhs]), const_cast<const object_type &>(instances[lhs]));</div><div class="line"><a name="l00542"></a><span class="lineno"> 542</span>  });</div><div class="line"><a name="l00543"></a><span class="lineno"> 543</span> </div><div class="line"><a name="l00544"></a><span class="lineno"> 544</span>  <span class="keywordflow">for</span>(<a class="code" href="classentt_1_1SparseSet_3_01Entity_01_4.html#a20c218a69cf339371251ffa5580d7aa0">pos_type</a> i = 0; i < copy.size(); ++i) {</div><div class="line"><a name="l00545"></a><span class="lineno"> 545</span>  <span class="keyword">auto</span> curr = i;</div><div class="line"><a name="l00546"></a><span class="lineno"> 546</span>  <span class="keyword">auto</span> next = copy[curr];</div><div class="line"><a name="l00547"></a><span class="lineno"> 547</span> </div><div class="line"><a name="l00548"></a><span class="lineno"> 548</span>  <span class="keywordflow">while</span>(curr != next) {</div><div class="line"><a name="l00549"></a><span class="lineno"> 549</span>  <span class="keyword">auto</span> lhs = copy[curr];</div><div class="line"><a name="l00550"></a><span class="lineno"> 550</span>  <span class="keyword">auto</span> rhs = copy[next];</div><div class="line"><a name="l00551"></a><span class="lineno"> 551</span>  std::swap(instances[lhs], instances[rhs]);</div><div class="line"><a name="l00552"></a><span class="lineno"> 552</span>  underlying_type::swap(lhs, rhs);</div><div class="line"><a name="l00553"></a><span class="lineno"> 553</span>  copy[curr] = curr;</div><div class="line"><a name="l00554"></a><span class="lineno"> 554</span>  curr = next;</div><div class="line"><a name="l00555"></a><span class="lineno"> 555</span>  next = copy[curr];</div><div class="line"><a name="l00556"></a><span class="lineno"> 556</span>  }</div><div class="line"><a name="l00557"></a><span class="lineno"> 557</span>  }</div><div class="line"><a name="l00558"></a><span class="lineno"> 558</span>  }</div><div class="line"><a name="l00559"></a><span class="lineno"> 559</span> </div><div class="line"><a name="l00582"></a><span class="lineno"><a class="line" href="classentt_1_1SparseSet_3_01Entity_00_01Type_01_4.html#a73083f2d8385f8e33aebfadb2f657e7d"> 582</a></span>  <span class="keywordtype">void</span> <a class="code" href="classentt_1_1SparseSet_3_01Entity_00_01Type_01_4.html#a73083f2d8385f8e33aebfadb2f657e7d">respect</a>(<span class="keyword">const</span> <a class="code" href="classentt_1_1SparseSet_3_01Entity_01_4.html">SparseSet<Entity></a> &other) noexcept <span class="keyword">override</span> {</div><div class="line"><a name="l00583"></a><span class="lineno"> 583</span>  <span class="keyword">auto</span> from = other.begin();</div><div class="line"><a name="l00584"></a><span class="lineno"> 584</span>  <span class="keyword">auto</span> to = other.end();</div><div class="line"><a name="l00585"></a><span class="lineno"> 585</span> </div><div class="line"><a name="l00586"></a><span class="lineno"> 586</span>  <a class="code" href="classentt_1_1SparseSet_3_01Entity_01_4.html#a20c218a69cf339371251ffa5580d7aa0">pos_type</a> pos = underlying_type::size() - 1;</div><div class="line"><a name="l00587"></a><span class="lineno"> 587</span>  <span class="keyword">const</span> <span class="keyword">auto</span> *direct = underlying_type::data();</div><div class="line"><a name="l00588"></a><span class="lineno"> 588</span> </div><div class="line"><a name="l00589"></a><span class="lineno"> 589</span>  <span class="keywordflow">while</span>(pos > 0 && from != to) {</div><div class="line"><a name="l00590"></a><span class="lineno"> 590</span>  <span class="keywordflow">if</span>(underlying_type::has(*from)) {</div><div class="line"><a name="l00591"></a><span class="lineno"> 591</span>  <span class="keywordflow">if</span>(*from != *(direct + pos)) {</div><div class="line"><a name="l00592"></a><span class="lineno"> 592</span>  <span class="keyword">auto</span> candidate = underlying_type::get(*from);</div><div class="line"><a name="l00593"></a><span class="lineno"> 593</span>  std::swap(instances[pos], instances[candidate]);</div><div class="line"><a name="l00594"></a><span class="lineno"> 594</span>  underlying_type::swap(pos, candidate);</div><div class="line"><a name="l00595"></a><span class="lineno"> 595</span>  }</div><div class="line"><a name="l00596"></a><span class="lineno"> 596</span> </div><div class="line"><a name="l00597"></a><span class="lineno"> 597</span>  --pos;</div><div class="line"><a name="l00598"></a><span class="lineno"> 598</span>  }</div><div class="line"><a name="l00599"></a><span class="lineno"> 599</span> </div><div class="line"><a name="l00600"></a><span class="lineno"> 600</span>  ++from;</div><div class="line"><a name="l00601"></a><span class="lineno"> 601</span>  }</div><div class="line"><a name="l00602"></a><span class="lineno"> 602</span>  }</div><div class="line"><a name="l00603"></a><span class="lineno"> 603</span> </div><div class="line"><a name="l00607"></a><span class="lineno"><a class="line" href="classentt_1_1SparseSet_3_01Entity_00_01Type_01_4.html#a3b138c121f11592a3f9e9f2fc2bb67fe"> 607</a></span>  <span class="keywordtype">void</span> <a class="code" href="classentt_1_1SparseSet_3_01Entity_00_01Type_01_4.html#a3b138c121f11592a3f9e9f2fc2bb67fe">reset</a>()<span class="keyword"> override </span>{</div><div class="line"><a name="l00608"></a><span class="lineno"> 608</span>  underlying_type::reset();</div><div class="line"><a name="l00609"></a><span class="lineno"> 609</span>  instances.clear();</div><div class="line"><a name="l00610"></a><span class="lineno"> 610</span>  }</div><div class="line"><a name="l00611"></a><span class="lineno"> 611</span> </div><div class="line"><a name="l00612"></a><span class="lineno"> 612</span> <span class="keyword">private</span>:</div><div class="line"><a name="l00613"></a><span class="lineno"> 613</span>  std::vector<object_type> instances;</div><div class="line"><a name="l00614"></a><span class="lineno"> 614</span> };</div><div class="line"><a name="l00615"></a><span class="lineno"> 615</span> </div><div class="line"><a name="l00616"></a><span class="lineno"> 616</span> </div><div class="line"><a name="l00617"></a><span class="lineno"> 617</span> }</div><div class="line"><a name="l00618"></a><span class="lineno"> 618</span> </div><div class="line"><a name="l00619"></a><span class="lineno"> 619</span> </div><div class="line"><a name="l00620"></a><span class="lineno"> 620</span> <span class="preprocessor">#endif // ENTT_ENTITY_SPARSE_SET_HPP</span></div><div class="ttc" id="classentt_1_1SparseSet_3_01Entity_00_01Type_01_4_html_a91cbe1334ba5135e44dab73adedbad8d"><div class="ttname"><a href="classentt_1_1SparseSet_3_01Entity_00_01Type_01_4.html#a91cbe1334ba5135e44dab73adedbad8d">entt::SparseSet< Entity, Type >::sort</a></div><div class="ttdeci">void sort(Compare compare)</div><div class="ttdoc">Sort components according to the given comparison function. </div><div class="ttdef"><b>Definition:</b> <a href="sparse__set_8hpp_source.html#l00536">sparse_set.hpp:536</a></div></div>
|
|
<div class="ttc" id="classentt_1_1SparseSet_3_01Entity_01_4_html_ad1c62c65aeb0112e688f05d8f641cdab"><div class="ttname"><a href="classentt_1_1SparseSet_3_01Entity_01_4.html#ad1c62c65aeb0112e688f05d8f641cdab">entt::SparseSet< Entity >::reset</a></div><div class="ttdeci">virtual void reset()</div><div class="ttdoc">Resets a sparse set. </div><div class="ttdef"><b>Definition:</b> <a href="sparse__set_8hpp_source.html#l00341">sparse_set.hpp:341</a></div></div>
|
|
<div class="ttc" id="namespaceentt_html"><div class="ttname"><a href="namespaceentt.html">entt</a></div><div class="ttdoc">EnTT default namespace. </div><div class="ttdef"><b>Definition:</b> <a href="family_8hpp_source.html#l00009">family.hpp:9</a></div></div>
|
|
<div class="ttc" id="classentt_1_1SparseSet_3_01Entity_00_01Type_01_4_html_a3b138c121f11592a3f9e9f2fc2bb67fe"><div class="ttname"><a href="classentt_1_1SparseSet_3_01Entity_00_01Type_01_4.html#a3b138c121f11592a3f9e9f2fc2bb67fe">entt::SparseSet< Entity, Type >::reset</a></div><div class="ttdeci">void reset() override</div><div class="ttdoc">Resets a sparse set. </div><div class="ttdef"><b>Definition:</b> <a href="sparse__set_8hpp_source.html#l00607">sparse_set.hpp:607</a></div></div>
|
|
<div class="ttc" id="classentt_1_1SparseSet_3_01Entity_01_4_html_a9d6b9c98d2645d821c81ff7d3586ca27"><div class="ttname"><a href="classentt_1_1SparseSet_3_01Entity_01_4.html#a9d6b9c98d2645d821c81ff7d3586ca27">entt::SparseSet< Entity >::empty</a></div><div class="ttdeci">bool empty() const noexcept</div><div class="ttdoc">Checks whether a sparse set is empty. </div><div class="ttdef"><b>Definition:</b> <a href="sparse__set_8hpp_source.html#l00138">sparse_set.hpp:138</a></div></div>
|
|
<div class="ttc" id="classentt_1_1SparseSet_3_01Entity_00_01Type_01_4_html_a73083f2d8385f8e33aebfadb2f657e7d"><div class="ttname"><a href="classentt_1_1SparseSet_3_01Entity_00_01Type_01_4.html#a73083f2d8385f8e33aebfadb2f657e7d">entt::SparseSet< Entity, Type >::respect</a></div><div class="ttdeci">void respect(const SparseSet< Entity > &other) noexcept override</div><div class="ttdoc">Sort components according to the order of the entities in another sparse set. </div><div class="ttdef"><b>Definition:</b> <a href="sparse__set_8hpp_source.html#l00582">sparse_set.hpp:582</a></div></div>
|
|
<div class="ttc" id="classentt_1_1SparseSet_html"><div class="ttname"><a href="classentt_1_1SparseSet.html">entt::SparseSet</a></div><div class="ttdoc">Sparse set. </div><div class="ttdef"><b>Definition:</b> <a href="sparse__set_8hpp_source.html#l00025">sparse_set.hpp:25</a></div></div>
|
|
<div class="ttc" id="classentt_1_1SparseSet_3_01Entity_01_4_html_ab81c48dcee7a1104ee82794613ee7ed2"><div class="ttname"><a href="classentt_1_1SparseSet_3_01Entity_01_4.html#ab81c48dcee7a1104ee82794613ee7ed2">entt::SparseSet< Entity >::size_type</a></div><div class="ttdeci">std::size_t size_type</div><div class="ttdoc">Unsigned integer type. </div><div class="ttdef"><b>Definition:</b> <a href="sparse__set_8hpp_source.html#l00100">sparse_set.hpp:100</a></div></div>
|
|
<div class="ttc" id="classentt_1_1SparseSet_3_01Entity_00_01Type_01_4_html"><div class="ttname"><a href="classentt_1_1SparseSet_3_01Entity_00_01Type_01_4.html">entt::SparseSet< Entity, Type ></a></div><div class="ttdoc">Extended sparse set implementation. </div><div class="ttdef"><b>Definition:</b> <a href="sparse__set_8hpp_source.html#l00375">sparse_set.hpp:375</a></div></div>
|
|
<div class="ttc" id="classentt_1_1SparseSet_3_01Entity_00_01Type_01_4_html_a06b863abd1b457c48b7080e203b47a0f"><div class="ttname"><a href="classentt_1_1SparseSet_3_01Entity_00_01Type_01_4.html#a06b863abd1b457c48b7080e203b47a0f">entt::SparseSet< Entity, Type >::destroy</a></div><div class="ttdeci">void destroy(entity_type entity) override</div><div class="ttdoc">Removes an entity from a sparse set and destroies its object. </div><div class="ttdef"><b>Definition:</b> <a href="sparse__set_8hpp_source.html#l00506">sparse_set.hpp:506</a></div></div>
|
|
<div class="ttc" id="classentt_1_1SparseSet_3_01Entity_01_4_html_a7d36e852257a965a9a0ed3fb636433e2"><div class="ttname"><a href="classentt_1_1SparseSet_3_01Entity_01_4.html#a7d36e852257a965a9a0ed3fb636433e2">entt::SparseSet< Entity >::entity_type</a></div><div class="ttdeci">Entity entity_type</div><div class="ttdoc">Underlying entity identifier. </div><div class="ttdef"><b>Definition:</b> <a href="sparse__set_8hpp_source.html#l00096">sparse_set.hpp:96</a></div></div>
|
|
<div class="ttc" id="classentt_1_1SparseSet_3_01Entity_01_4_html_a1ad77aed1e49af60b61044c996969b9a"><div class="ttname"><a href="classentt_1_1SparseSet_3_01Entity_01_4.html#a1ad77aed1e49af60b61044c996969b9a">entt::SparseSet< Entity >::iterator_type</a></div><div class="ttdeci">Iterator iterator_type</div><div class="ttdoc">Input iterator type. </div><div class="ttdef"><b>Definition:</b> <a href="sparse__set_8hpp_source.html#l00102">sparse_set.hpp:102</a></div></div>
|
|
<div class="ttc" id="classentt_1_1SparseSet_3_01Entity_01_4_html"><div class="ttname"><a href="classentt_1_1SparseSet_3_01Entity_01_4.html">entt::SparseSet< Entity ></a></div><div class="ttdoc">Basic sparse set implementation. </div><div class="ttdef"><b>Definition:</b> <a href="sparse__set_8hpp_source.html#l00056">sparse_set.hpp:56</a></div></div>
|
|
<div class="ttc" id="classentt_1_1SparseSet_3_01Entity_01_4_html_a1b6a33e6e65345bf028877efa74c5a5e"><div class="ttname"><a href="classentt_1_1SparseSet_3_01Entity_01_4.html#a1b6a33e6e65345bf028877efa74c5a5e">entt::SparseSet< Entity >::has</a></div><div class="ttdeci">bool has(entity_type entity) const noexcept</div><div class="ttdoc">Checks if a sparse set contains an entity. </div><div class="ttdef"><b>Definition:</b> <a href="sparse__set_8hpp_source.html#l00199">sparse_set.hpp:199</a></div></div>
|
|
<div class="ttc" id="classentt_1_1SparseSet_3_01Entity_01_4_html_a20c218a69cf339371251ffa5580d7aa0"><div class="ttname"><a href="classentt_1_1SparseSet_3_01Entity_01_4.html#a20c218a69cf339371251ffa5580d7aa0">entt::SparseSet< Entity >::pos_type</a></div><div class="ttdeci">entity_type pos_type</div><div class="ttdoc">Entity dependent position type. </div><div class="ttdef"><b>Definition:</b> <a href="sparse__set_8hpp_source.html#l00098">sparse_set.hpp:98</a></div></div>
|
|
<div class="ttc" id="classentt_1_1SparseSet_3_01Entity_00_01Type_01_4_html_af7db79dfb4e031a63fa526d4f7d54915"><div class="ttname"><a href="classentt_1_1SparseSet_3_01Entity_00_01Type_01_4.html#af7db79dfb4e031a63fa526d4f7d54915">entt::SparseSet< Entity, Type >::object_type</a></div><div class="ttdeci">Type object_type</div><div class="ttdoc">Type of the objects associated to the entities. </div><div class="ttdef"><b>Definition:</b> <a href="sparse__set_8hpp_source.html#l00380">sparse_set.hpp:380</a></div></div>
|
|
<div class="ttc" id="classentt_1_1SparseSet_3_01Entity_01_4_html_a6e4dda542e3d725dd963dea57bfb9cb1"><div class="ttname"><a href="classentt_1_1SparseSet_3_01Entity_01_4.html#a6e4dda542e3d725dd963dea57bfb9cb1">entt::SparseSet< Entity >::data</a></div><div class="ttdeci">const entity_type * data() const noexcept</div><div class="ttdoc">Direct access to the internal packed array. </div><div class="ttdef"><b>Definition:</b> <a href="sparse__set_8hpp_source.html#l00157">sparse_set.hpp:157</a></div></div>
|
|
<div class="ttc" id="classentt_1_1SparseSet_3_01Entity_01_4_html_a2c54395d55054437bfe179718e102181"><div class="ttname"><a href="classentt_1_1SparseSet_3_01Entity_01_4.html#a2c54395d55054437bfe179718e102181">entt::SparseSet< Entity >::end</a></div><div class="ttdeci">iterator_type end() const noexcept</div><div class="ttdoc">Returns an iterator to the end. </div><div class="ttdef"><b>Definition:</b> <a href="sparse__set_8hpp_source.html#l00190">sparse_set.hpp:190</a></div></div>
|
|
<div class="ttc" id="classentt_1_1SparseSet_3_01Entity_01_4_html_ab4be1be8435da50621373c0bd737a1e8"><div class="ttname"><a href="classentt_1_1SparseSet_3_01Entity_01_4.html#ab4be1be8435da50621373c0bd737a1e8">entt::SparseSet< Entity >::destroy</a></div><div class="ttdeci">virtual void destroy(entity_type entity)</div><div class="ttdoc">Removes an entity from a sparse set. </div><div class="ttdef"><b>Definition:</b> <a href="sparse__set_8hpp_source.html#l00264">sparse_set.hpp:264</a></div></div>
|
|
<div class="ttc" id="classentt_1_1SparseSet_3_01Entity_01_4_html_a1efc9899f2ede4fd8ea1840a7ed8dbc7"><div class="ttname"><a href="classentt_1_1SparseSet_3_01Entity_01_4.html#a1efc9899f2ede4fd8ea1840a7ed8dbc7">entt::SparseSet< Entity >::begin</a></div><div class="ttdeci">iterator_type begin() const noexcept</div><div class="ttdoc">Returns an iterator to the beginning. </div><div class="ttdef"><b>Definition:</b> <a href="sparse__set_8hpp_source.html#l00173">sparse_set.hpp:173</a></div></div>
|
|
<div class="ttc" id="classentt_1_1SparseSet_3_01Entity_01_4_html_adb65da9a09f41dcf6ec433066a7891c3"><div class="ttname"><a href="classentt_1_1SparseSet_3_01Entity_01_4.html#adb65da9a09f41dcf6ec433066a7891c3">entt::SparseSet< Entity >::construct</a></div><div class="ttdeci">void construct(entity_type entity)</div><div class="ttdoc">Assigns an entity to a sparse set. </div><div class="ttdef"><b>Definition:</b> <a href="sparse__set_8hpp_source.html#l00237">sparse_set.hpp:237</a></div></div>
|
|
<div class="ttc" id="classentt_1_1SparseSet_3_01Entity_00_01Type_01_4_html_aa31e003cb882774dfb81fabb5d88e554"><div class="ttname"><a href="classentt_1_1SparseSet_3_01Entity_00_01Type_01_4.html#aa31e003cb882774dfb81fabb5d88e554">entt::SparseSet< Entity, Type >::construct</a></div><div class="ttdeci">object_type & construct(entity_type entity, Args &&... args)</div><div class="ttdoc">Assigns an entity to a sparse set and constructs its object. </div><div class="ttdef"><b>Definition:</b> <a href="sparse__set_8hpp_source.html#l00488">sparse_set.hpp:488</a></div></div>
|
|
<div class="ttc" id="namespaceentt_html_a18e1a7cdfcb0c0ba075e0beeda95285f"><div class="ttname"><a href="namespaceentt.html#a18e1a7cdfcb0c0ba075e0beeda95285f">entt::operator!=</a></div><div class="ttdeci">constexpr bool operator!=(const HashedString &lhs, const HashedString &rhs) noexcept</div><div class="ttdoc">Compares two hashed strings. </div><div class="ttdef"><b>Definition:</b> <a href="hashed__string_8hpp_source.html#l00101">hashed_string.hpp:101</a></div></div>
|
|
<div class="ttc" id="classentt_1_1SparseSet_3_01Entity_01_4_html_a7a6ff2340d8accf14bdaa83676cbc670"><div class="ttname"><a href="classentt_1_1SparseSet_3_01Entity_01_4.html#a7a6ff2340d8accf14bdaa83676cbc670">entt::SparseSet< Entity >::respect</a></div><div class="ttdeci">virtual void respect(const SparseSet< Entity > &other) noexcept</div><div class="ttdoc">Sort entities according to their order in another sparse set. </div><div class="ttdef"><b>Definition:</b> <a href="sparse__set_8hpp_source.html#l00319">sparse_set.hpp:319</a></div></div>
|
|
<div class="ttc" id="classentt_1_1SparseSet_3_01Entity_00_01Type_01_4_html_ac64be22bc7dcb2498257dccbbcfa004f"><div class="ttname"><a href="classentt_1_1SparseSet_3_01Entity_00_01Type_01_4.html#ac64be22bc7dcb2498257dccbbcfa004f">entt::SparseSet< Entity, Type >::raw</a></div><div class="ttdeci">object_type * raw() noexcept</div><div class="ttdoc">Direct access to the array of objects. </div><div class="ttdef"><b>Definition:</b> <a href="sparse__set_8hpp_source.html#l00437">sparse_set.hpp:437</a></div></div>
|
|
<div class="ttc" id="classentt_1_1SparseSet_3_01Entity_01_4_html_af122c1668ab1efbe0eca5792e9bae434"><div class="ttname"><a href="classentt_1_1SparseSet_3_01Entity_01_4.html#af122c1668ab1efbe0eca5792e9bae434">entt::SparseSet< Entity >::swap</a></div><div class="ttdeci">void swap(pos_type lhs, pos_type rhs) noexcept</div><div class="ttdoc">Swaps the position of two entities in the internal packed array. </div><div class="ttdef"><b>Definition:</b> <a href="sparse__set_8hpp_source.html#l00293">sparse_set.hpp:293</a></div></div>
|
|
<div class="ttc" id="structentt_1_1entt__traits_html"><div class="ttname"><a href="structentt_1_1entt__traits.html">entt::entt_traits</a></div><div class="ttdoc">Entity traits. </div><div class="ttdef"><b>Definition:</b> <a href="traits_8hpp_source.html#l00018">traits.hpp:18</a></div></div>
|
|
</div><!-- fragment --></div><!-- contents -->
|
|
<!-- start footer part -->
|
|
<hr class="footer"/><address class="footer"><small>
|
|
Generated by  <a href="http://www.doxygen.org/index.html">
|
|
<img class="footer" src="doxygen.png" alt="doxygen"/>
|
|
</a> 1.8.13
|
|
</small></address>
|
|
</body>
|
|
</html>
|