Files
entt/md_docs_2md_2container.html
2025-03-19 15:49:42 +01:00

151 lines
8.1 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" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.13.2"/>
<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>
<script type="text/javascript" src="clipboard.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="cookie.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-awesome.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 id="projectrow">
<td id="projectalign">
<div id="projectname">EnTT<span id="projectnumber">&#160;3.15.0</span>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.13.2 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search/",'.html');
/* @license-end */
</script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() { codefold.init(0); });
/* @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:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
initMenu('',true,false,'search.php','Search',false);
$(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function(){ initResizable(false); });
/* @license-end */
</script>
<!-- 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">
<div id="MSearchResults">
<div class="SRPage">
<div id="SRIndex">
<div id="SRResults"></div>
<div class="SRStatus" id="Loading">Loading...</div>
<div class="SRStatus" id="Searching">Searching...</div>
<div class="SRStatus" id="NoMatches">No Matches</div>
</div>
</div>
</div>
</div>
</div><!-- top -->
<div id="doc-content">
<div><div class="header">
<div class="headertitle"><div class="title">Crash Course: containers</div></div>
</div><!--header-->
<div class="contents">
<div class="textblock"><p><a class="anchor" id="crash-course-containers"></a></p>
<h1><a class="anchor" id="table-of-contents-1"></a>
Table of Contents</h1>
<ul>
<li><a class="el" href="md_docs_2md_2config.html#introduction">Introduction</a></li>
<li><a class="el" href="#containers">Containers</a><ul>
<li><a class="el" href="#dense-map">Dense map</a></li>
<li><a class="el" href="#dense-set">Dense set</a></li>
</ul>
</li>
<li><a class="el" href="#adaptors">Adaptors</a><ul>
<li><a class="el" href="#table">Table</a></li>
</ul>
</li>
</ul>
<h1><a class="anchor" id="introduction-1"></a>
Introduction</h1>
<p>The standard C++ library offers a wide range of containers and adaptors already. It is really difficult to do better (although it is very easy to do worse, as many examples available online demonstrate).<br />
<code>EnTT</code> does not 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 functionalities by making available some containers and adaptors initially developed for internal use.</p>
<p>This section of the library is likely to grow larger over time. However, for the moment it is quite small and mainly aimed at satisfying some internal needs.<br />
For all containers and adaptors made available, full test coverage and stability over time is guaranteed as usual.</p>
<h1><a class="anchor" id="containers"></a>
Containers</h1>
<h2><a class="anchor" id="dense-map"></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, the <code>std::unordered_map</code> class.<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="dense-set"></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, the <code>std::unordered_set</code> class.<br />
However, this type of set also supports reverse iteration and therefore offers all the functions necessary for the purpose (such as <code>rbegin</code> and <code>rend</code>).</p>
<h1><a class="anchor" id="adaptors"></a>
Adaptors</h1>
<h2><a class="anchor" id="table"></a>
Table</h2>
<p>The <code>basic_table</code> class is a container adaptor which manages multiple sequential containers together, treating them as different columns of the same table.<br />
The <code>table</code> alias allows users to provide only the types to handle, using <code>std::vector</code> as the default sequential container.</p>
<p>Only a small set of functions is provided, although very close to what the API of the <code>std::vector</code> class offers.<br />
The internal implementation is purposely supported by a tuple of containers rather than a container of tuples. The purpose is to allow efficient access to single columns and not just access to the entire data set of the table.</p>
<p>When a row is accessed, all data is returned in the form of a tuple containing (possibly const) references to the elements of the row itself.<br />
Similarly, when a table is iterated, tuples of references to table elements are returned for each row. </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.13.2
</small></address>
</div><!-- doc-content -->
</body>
</html>