Files
entt/md_docs_md_container.html
2022-04-18 19:54:29 +02:00

104 lines
5.7 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://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.9.1"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>EnTT: Crash Course: containers</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
&#160;<span id="projectnumber">3.10.0</span>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.1 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search','.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
initMenu('',true,false,'search.php','Search');
$(document).ready(function() { init_search(); });
});
/* @license-end */</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><!-- top -->
<div class="PageDoc"><div class="header">
<div class="headertitle">
<div class="title">Crash Course: containers </div> </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><h1><a class="anchor" id="autotoc_md13"></a>
Introduction</h1>
<p>The standard C++ library offers a wide range of containers and it's really difficult to do better (although it's very easy to do worse, as many examples available online demonstrate).<br />
<code>EnTT</code> doesn't try in any way to replace what is offered by the standard. Quite the opposite, given the widespread use that is made of standard containers.<br />
However, the library also tries to fill a gap in features and functionality by making available some containers initially developed for internal use.</p>
<p>This section of the library is likely to grow larger over time. However, for the moment it's quite small and mainly aimed at satisfying some internal needs.<br />
For all containers made available, full test coverage and stability over time is guaranteed as usual.</p>
<h1><a class="anchor" id="autotoc_md14"></a>
Containers</h1>
<h2><a class="anchor" id="autotoc_md15"></a>
Dense map</h2>
<p>The dense map made available in <code>EnTT</code> is a hash map that aims to return a packed array of elements, so as to reduce the number of jumps in memory during iterations.<br />
The implementation is based on <em>sparse sets</em> and each bucket is identified by an implicit list within the packed array itself.</p>
<p>The interface is very close to its counterpart in the standard library, that is, <code>std::unordered_map</code>.<br />
However, both local and non-local iterators returned by a dense map belong to the input iterator category although they respectively model the concepts of a <em>forward iterator</em> type and a <em>random access iterator</em> type.<br />
This is because they return a pair of references rather than a reference to a pair. In other words, dense maps return a so called <em>proxy iterator</em> the value type of which is:</p>
<ul>
<li><code>std::pair&lt;const Key &amp;, Type &amp;&gt;</code> for non-const iterator types.</li>
<li><code>std::pair&lt;const Key &amp;, const Type &amp;&gt;</code> for const iterator types.</li>
</ul>
<p>This is quite different from what any standard library map returns and should be taken into account when looking for a drop-in replacement.</p>
<h2><a class="anchor" id="autotoc_md16"></a>
Dense set</h2>
<p>The dense set made available in <code>EnTT</code> is a hash set that aims to return a packed array of elements, so as to reduce the number of jumps in memory during iterations.<br />
The implementation is based on <em>sparse sets</em> and each bucket is identified by an implicit list within the packed array itself.</p>
<p>The interface is in all respects similar to its counterpart in the standard library, that is, <code>std::unordered_set</code>.<br />
Therefore, there is no need to go into the API description. </p>
</div></div><!-- contents -->
</div><!-- PageDoc -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.1
</small></address>
</body>
</html>