Added initial bitset documentation
This commit is contained in:
1 parent
b35281b8dc
commit
9962981047
44 files changed
+505
-61
No files matched your search
+72
-5
@@ -83,7 +83,7 @@
|
||||
|
||||
<nav id="sidebar" class="sidebar" aria-label="Table of contents">
|
||||
<div id="sidebar-scrollbox" class="sidebar-scrollbox">
|
||||
<ol class="chapter"><li class="expanded "><a href="Introduction/introduction.html"><strong aria-hidden="true">1.</strong> Introduction</a></li><li><ol class="section"><li class="expanded "><a href="Introduction/why_this_library.html"><strong aria-hidden="true">1.1.</strong> Why this library</a></li><li class="expanded "><a href="Introduction/how_to_install.html"><strong aria-hidden="true">1.2.</strong> How to install</a></li><li class="expanded "><a href="Introduction/library_structure.html"><strong aria-hidden="true">1.3.</strong> Library structure</a></li><li class="expanded "><a href="Introduction/understanding_the_library.html"><strong aria-hidden="true">1.4.</strong> Understanding the library</a></li><li class="expanded "><a href="Introduction/how_to_use_the_library.html"><strong aria-hidden="true">1.5.</strong> How to use the library</a></li></ol></li><li class="expanded "><a href="Overview/index.html"><strong aria-hidden="true">2.</strong> Overview</a></li><li><ol class="section"><li class="expanded "><a href="Overview/collections_overview.html"><strong aria-hidden="true">2.1.</strong> Collections Overview</a></li><li class="expanded "><a href="Overview/features_overview.html"><strong aria-hidden="true">2.2.</strong> Features Overview</a></li><li class="expanded "><a href="Overview/files_overview.html"><strong aria-hidden="true">2.3.</strong> Files Overview</a></li></ol></li><li class="expanded "><a href="cor/index.html"><strong aria-hidden="true">3.</strong> cor</a></li><li><ol class="section"><li class="expanded "><a href="cor/callbacks/index.html"><strong aria-hidden="true">3.1.</strong> Callbacks</a></li><li class="expanded "><a href="cor/custom_allocation/index.html"><strong aria-hidden="true">3.2.</strong> Custom allocation</a></li><li class="expanded "><a href="cor/error_codes/index.html"><strong aria-hidden="true">3.3.</strong> Error Codes</a></li><li class="expanded "><a href="cor/functions_table/index.html"><strong aria-hidden="true">3.4.</strong> Functions Table</a></li><li class="expanded "><a href="cor/iterators/index.html"><strong aria-hidden="true">3.5.</strong> Iterators</a></li></ol></li><li class="expanded "><a href="cmc/index.html"><strong aria-hidden="true">4.</strong> cmc</a></li><li><ol class="section"><li class="expanded "><a href="cmc/deque.h/index.html"><strong aria-hidden="true">4.1.</strong> deque.h</a></li><li><ol class="section"><li class="expanded "><a href="cmc/deque.h/functions.html"><strong aria-hidden="true">4.1.1.</strong> Functions.h</a></li></ol></li></ol></li><li class="expanded "><a href="dev/index.html"><strong aria-hidden="true">5.</strong> dev</a></li><li class="expanded "><a href="sac/index.html"><strong aria-hidden="true">6.</strong> sac</a></li><li class="expanded "><a href="utl/index.html"><strong aria-hidden="true">7.</strong> utl</a></li><li><ol class="section"><li class="expanded "><a href="utl/assert.h/index.html"><strong aria-hidden="true">7.1.</strong> assert.h</a></li><li><ol class="section"><li class="expanded "><a href="utl/assert.h/overview.html"><strong aria-hidden="true">7.1.1.</strong> Overview</a></li><li class="expanded "><a href="utl/assert.h/valued_assertions.html"><strong aria-hidden="true">7.1.2.</strong> Valued Assertions</a></li><li class="expanded "><a href="utl/assert.h/generic_assertions.html"><strong aria-hidden="true">7.1.3.</strong> Generic Assertions</a></li></ol></li><li class="expanded "><a href="utl/foreach.h/index.html"><strong aria-hidden="true">7.2.</strong> foreach.h</a></li><li class="expanded "><a href="utl/futils.h/index.html"><strong aria-hidden="true">7.3.</strong> futils.h</a></li><li class="expanded "><a href="utl/log.h/index.html"><strong aria-hidden="true">7.4.</strong> log.h</a></li><li><ol class="section"><li class="expanded "><a href="utl/log.h/log_functions.html"><strong aria-hidden="true">7.4.1.</strong> Log Functions</a></li><li class="expanded "><a href="utl/log.h/configuration.html"><strong aria-hidden="true">7.4.2.</strong> Configuration</a></li><li class="expanded "><a href="utl/log.h/meanings.html"><strong aria-hidden="true">7.4.3.</strong> Meanings</a></li></ol></li><li class="expanded "><a href="utl/test.h/index.html"><strong aria-hidden="true">7.5.</strong> test.h</a></li><li class="expanded "><a href="utl/timer.h/index.html"><strong aria-hidden="true">7.6.</strong> timer.h</a></li></ol></li><li class="expanded "><a href="Examples/examples.html"><strong aria-hidden="true">8.</strong> Examples</a></li></ol>
|
||||
<ol class="chapter"><li class="expanded "><a href="Introduction/introduction.html"><strong aria-hidden="true">1.</strong> Introduction</a></li><li><ol class="section"><li class="expanded "><a href="Introduction/why_this_library.html"><strong aria-hidden="true">1.1.</strong> Why this library</a></li><li class="expanded "><a href="Introduction/how_to_install.html"><strong aria-hidden="true">1.2.</strong> How to install</a></li><li class="expanded "><a href="Introduction/library_structure.html"><strong aria-hidden="true">1.3.</strong> Library structure</a></li><li class="expanded "><a href="Introduction/understanding_the_library.html"><strong aria-hidden="true">1.4.</strong> Understanding the library</a></li><li class="expanded "><a href="Introduction/how_to_use_the_library.html"><strong aria-hidden="true">1.5.</strong> How to use the library</a></li></ol></li><li class="expanded "><a href="Overview/index.html"><strong aria-hidden="true">2.</strong> Overview</a></li><li><ol class="section"><li class="expanded "><a href="Overview/collections_overview.html"><strong aria-hidden="true">2.1.</strong> Collections Overview</a></li><li class="expanded "><a href="Overview/features_overview.html"><strong aria-hidden="true">2.2.</strong> Features Overview</a></li><li class="expanded "><a href="Overview/files_overview.html"><strong aria-hidden="true">2.3.</strong> Files Overview</a></li></ol></li><li class="expanded "><a href="cor/index.html"><strong aria-hidden="true">3.</strong> cor</a></li><li><ol class="section"><li class="expanded "><a href="cor/callbacks/index.html"><strong aria-hidden="true">3.1.</strong> Callbacks</a></li><li class="expanded "><a href="cor/custom_allocation/index.html"><strong aria-hidden="true">3.2.</strong> Custom allocation</a></li><li class="expanded "><a href="cor/error_codes/index.html"><strong aria-hidden="true">3.3.</strong> Error Codes</a></li><li class="expanded "><a href="cor/functions_table/index.html"><strong aria-hidden="true">3.4.</strong> Functions Table</a></li><li class="expanded "><a href="cor/iterators/index.html"><strong aria-hidden="true">3.5.</strong> Iterators</a></li></ol></li><li class="expanded "><a href="cmc/index.html"><strong aria-hidden="true">4.</strong> cmc</a></li><li><ol class="section"><li class="expanded "><a href="cmc/bitset.h/index.html"><strong aria-hidden="true">4.1.</strong> bitset.h</a></li><li class="expanded "><a href="cmc/deque.h/index.html"><strong aria-hidden="true">4.2.</strong> deque.h</a></li><li><ol class="section"><li class="expanded "><a href="cmc/deque.h/functions.html"><strong aria-hidden="true">4.2.1.</strong> Functions.h</a></li></ol></li></ol></li><li class="expanded "><a href="dev/index.html"><strong aria-hidden="true">5.</strong> dev</a></li><li class="expanded "><a href="sac/index.html"><strong aria-hidden="true">6.</strong> sac</a></li><li class="expanded "><a href="utl/index.html"><strong aria-hidden="true">7.</strong> utl</a></li><li><ol class="section"><li class="expanded "><a href="utl/assert.h/index.html"><strong aria-hidden="true">7.1.</strong> assert.h</a></li><li><ol class="section"><li class="expanded "><a href="utl/assert.h/overview.html"><strong aria-hidden="true">7.1.1.</strong> Overview</a></li><li class="expanded "><a href="utl/assert.h/valued_assertions.html"><strong aria-hidden="true">7.1.2.</strong> Valued Assertions</a></li><li class="expanded "><a href="utl/assert.h/generic_assertions.html"><strong aria-hidden="true">7.1.3.</strong> Generic Assertions</a></li></ol></li><li class="expanded "><a href="utl/foreach.h/index.html"><strong aria-hidden="true">7.2.</strong> foreach.h</a></li><li class="expanded "><a href="utl/futils.h/index.html"><strong aria-hidden="true">7.3.</strong> futils.h</a></li><li class="expanded "><a href="utl/log.h/index.html"><strong aria-hidden="true">7.4.</strong> log.h</a></li><li><ol class="section"><li class="expanded "><a href="utl/log.h/log_functions.html"><strong aria-hidden="true">7.4.1.</strong> Log Functions</a></li><li class="expanded "><a href="utl/log.h/configuration.html"><strong aria-hidden="true">7.4.2.</strong> Configuration</a></li><li class="expanded "><a href="utl/log.h/meanings.html"><strong aria-hidden="true">7.4.3.</strong> Meanings</a></li></ol></li><li class="expanded "><a href="utl/test.h/index.html"><strong aria-hidden="true">7.5.</strong> test.h</a></li><li class="expanded "><a href="utl/timer.h/index.html"><strong aria-hidden="true">7.6.</strong> timer.h</a></li></ol></li><li class="expanded "><a href="Examples/examples.html"><strong aria-hidden="true">8.</strong> Examples</a></li></ol>
|
||||
</div>
|
||||
<div id="sidebar-resize-handle" class="sidebar-resize-handle"></div>
|
||||
</nav>
|
||||
@@ -641,6 +641,73 @@ int main(void)
|
||||
}
|
||||
</code></pre>
|
||||
<p>You can customize the functions prefix (<code>PFX</code>) and the <code>struct</code> name (<code>SNAME</code>). The macro <code>CMC_GENERATE_HASHMAP</code> will expand to all the code that you will need to operate on a HashMap with <code>char *</code> keys and <code>int</code> values. The only thing left to do is to define a hash function and a comparator functions for the keys of this map. In case of <code>char *</code> you can find these functions in <code>utl/futils.h</code> or make your own. To know which collections require which functions check out <a href="cmc/../cor/functions_table/index.html">Functions Table</a> or the documentation for each collection.</p>
|
||||
<h1><a class="header" href="#bitseth" id="bitseth">bitset.h</a></h1>
|
||||
<p>A Bit Set is an array where each bit can be individually modified and queried by using bitwise operators such as <code>|</code>, <code>&</code>, <code>^</code>, <code>~</code>, <code>>></code> and <code><<</code> (<code>or</code>, <code>and</code>, <code>xor</code>, <code>not</code>, <code>right shift</code>, <code>left shift</code> respectively).</p>
|
||||
<h2><a class="header" href="#bitset-implementation" id="bitset-implementation">BitSet Implementation</a></h2>
|
||||
<p>This BitSet implementation uses an array of type <code>cmc_bitset_word</code> which can be <code>typedef</code>ed to any unsigned type such as <code>uint8_t</code>, <code>uint16_t</code>, <code>uint32_t</code>, <code>uint64_t</code>, <code>size_t</code>, etc. The BitSet does not make use of <code>K</code> or <code>V</code>. Because of that, it also doesn't have Functions Tables.</p>
|
||||
<p>The BitSet is initialized with a custom capacity but, if a bit index accessed is greater than the total capacity, the BitSet will resize. This means that the BitSet will try to guarantee that every bit index is accessible, as long as there is enough memory.</p>
|
||||
<h2><a class="header" href="#bitset-generation-macros" id="bitset-generation-macros">BitSet Generation Macros</a></h2>
|
||||
<ul>
|
||||
<li><code>CMC_GENERATE_BITSET(PFX, SNAME)</code> - Generate full definition.</li>
|
||||
<li><code>CMC_GENERATE_BITSET_HEADER(PFX, SNAME)</code> - Generate only the header portion</li>
|
||||
<li><code>CMC_GENERATE_BITSET_SOURCE(PFX, SNAME)</code> - Generate only the source portion</li>
|
||||
</ul>
|
||||
<table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody>
|
||||
<tr><td><code>PFX</code></td><td>Functions namespace or prefix</td></tr>
|
||||
<tr><td><code>SNAME</code></td><td>Structure name</td></tr>
|
||||
</tbody></table>
|
||||
<h2><a class="header" href="#bitset-structures" id="bitset-structures">BitSet Structures</a></h2>
|
||||
<table><thead><tr><th>Declared structs</th><th>Description</th></tr></thead><tbody>
|
||||
<tr><td><code>struct SNAME</code></td><td>A bit set data structure</td></tr>
|
||||
<tr><td><code>struct SNAME##_iter</code></td><td>A bit set iterator</td></tr>
|
||||
</tbody></table>
|
||||
<h2><a class="header" href="#struct-sname" id="struct-sname">struct SNAME</a></h2>
|
||||
<table><thead><tr><th><code>struct SNAME</code></th><th>Description</th></tr></thead><tbody>
|
||||
<tr><td><code>cmc_bitset_word *buffer</code></td><td>Dynamic array of bits.</td></tr>
|
||||
<tr><td><code>size_t capacity</code></td><td>Current array capacity .</td></tr>
|
||||
<tr><td><code>int flag</code></td><td>Flag indicating errors or success.</td></tr>
|
||||
<tr><td><code>struct cmc_alloc_node *alloc</code></td><td>Custom allocation functions.</td></tr>
|
||||
<tr><td><code>struct cmc_callbacks *callbacks</code></td><td>Callback functions.</td></tr>
|
||||
</tbody></table>
|
||||
<h2><a class="header" href="#struct-sname_iter" id="struct-sname_iter">struct SNAME##_iter</a></h2>
|
||||
<table><thead><tr><th><code>struct SNAME##_iter</code></th><th>Description</th></tr></thead><tbody>
|
||||
<tr><td><code>struct SNAME *target</code></td><td>BitSet being iterated over.</td></tr>
|
||||
<tr><td><code>size_t cursor</code></td><td>Cursor's current position (index).</td></tr>
|
||||
<tr><td><code>bool start</code></td><td>If the iterator reached the start of the iteration.</td></tr>
|
||||
<tr><td><code>bool end</code></td><td>If the iterator reached the end of iteration.</td></tr>
|
||||
</tbody></table>
|
||||
<h2><a class="header" href="#cmc_bitset_word" id="cmc_bitset_word">cmc_bitset_word</a></h2>
|
||||
<p>The <code>typedef</code>ed data type o the underlying bit set buffer.</p>
|
||||
<pre><code class="language-c">typedef uint32_t cmc_bitset_word;
|
||||
</code></pre>
|
||||
<p>This <code>typedef</code> can be changed to any unsigned integer data type and the bit set will still work properly.</p>
|
||||
<h2><a class="header" href="#callbacks-1" id="callbacks-1">Callbacks</a></h2>
|
||||
<p>This list associates which functions calls which callbacks.</p>
|
||||
<ul>
|
||||
<li><code>create</code>
|
||||
<ul>
|
||||
<li><code>PFX##_set()</code></li>
|
||||
<li><code>PFX##_set_range()</code></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><code>read</code></li>
|
||||
<li><code>update</code></li>
|
||||
<li><code>delete</code>
|
||||
<ul>
|
||||
<li><code>PFX##_clear()</code></li>
|
||||
<li><code>PFX##_clear_range()</code></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><code>resize</code>
|
||||
<ul>
|
||||
<li><code>PFX##_resize()</code></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
<h2><a class="header" href="#functions-table-1" id="functions-table-1">Functions Table</a></h2>
|
||||
<table><thead><tr><th align="center">CMP</th><th align="center">CPY</th><th align="center">STR</th><th align="center">FREE</th><th align="center">HASH</th><th align="center">PRI</th></tr></thead><tbody>
|
||||
<tr><td align="center"><img src="https://placehold.it/20/2ef625/000000?text=+" alt="#2ef625" /></td><td align="center"><img src="https://placehold.it/20/2ef625/000000?text=+" alt="#2ef625" /></td><td align="center"><img src="https://placehold.it/20/2ef625/000000?text=+" alt="#2ef625" /></td><td align="center"><img src="https://placehold.it/20/2ef625/000000?text=+" alt="#2ef625" /></td><td align="center"><img src="https://placehold.it/20/2ef625/000000?text=+" alt="#2ef625" /></td><td align="center"><img src="https://placehold.it/20/2ef625/000000?text=+" alt="#2ef625" /></td></tr>
|
||||
</tbody></table>
|
||||
<h1><a class="header" href="#dequeh" id="dequeh">deque.h</a></h1>
|
||||
<p>A Deque, also known as a double-ended queue, is a linear data structure that is able to add and remove elements from both ends. It can also be thought of a double-ended stack since you can push and pop elements from two ends. The Deque can also be used as a Queue. The only elements accessible from a Deque ar the two elements at its ends (front element and back element).</p>
|
||||
<h2><a class="header" href="#deque-implementation" id="deque-implementation">Deque Implementation</a></h2>
|
||||
@@ -663,7 +730,7 @@ int main(void)
|
||||
<tr><td><code>struct SNAME##_fval</code></td><td>A function table for the <code>V</code> type</td></tr>
|
||||
<tr><td><code>struct SNAME##_iter</code></td><td>A double-ended queue iterator</td></tr>
|
||||
</tbody></table>
|
||||
<h2><a class="header" href="#struct-sname" id="struct-sname">struct SNAME</a></h2>
|
||||
<h2><a class="header" href="#struct-sname-1" id="struct-sname-1">struct SNAME</a></h2>
|
||||
<table><thead><tr><th><code>struct SNAME</code></th><th>Description</th></tr></thead><tbody>
|
||||
<tr><td><code>V *buffer</code></td><td>Dynamic circular array of elements.</td></tr>
|
||||
<tr><td><code>size_t capacity</code></td><td>Current circular array capacity.</td></tr>
|
||||
@@ -677,7 +744,7 @@ int main(void)
|
||||
</tbody></table>
|
||||
<h2><a class="header" href="#struct-sname_fval" id="struct-sname_fval">struct SNAME##_fval</a></h2>
|
||||
<p>The Functions Table for <code>V</code>. Check out the Functions Table documentation <a href="cmc/deque.h/../../cor/functions_table/index.html">here</a>.</p>
|
||||
<h2><a class="header" href="#struct-sname_iter" id="struct-sname_iter">struct SNAME##_iter</a></h2>
|
||||
<h2><a class="header" href="#struct-sname_iter-1" id="struct-sname_iter-1">struct SNAME##_iter</a></h2>
|
||||
<table><thead><tr><th><code>struct SNAME##_iter</code></th><th>Description</th></tr></thead><tbody>
|
||||
<tr><td><code>struct SNAME *target</code></td><td>Deque being iterated over.</td></tr>
|
||||
<tr><td><code>size_t cursor</code></td><td>Cursor's current position (index).</td></tr>
|
||||
@@ -685,7 +752,7 @@ int main(void)
|
||||
<tr><td><code>bool start</code></td><td>If the iterator reached the start of the iteration.</td></tr>
|
||||
<tr><td><code>bool end</code></td><td>If the iterator reached the end of iteration.</td></tr>
|
||||
</tbody></table>
|
||||
<h2><a class="header" href="#callbacks-1" id="callbacks-1">Callbacks</a></h2>
|
||||
<h2><a class="header" href="#callbacks-2" id="callbacks-2">Callbacks</a></h2>
|
||||
<p>This list associates which functions calls which callbacks.</p>
|
||||
<ul>
|
||||
<li><code>create</code>
|
||||
@@ -714,7 +781,7 @@ int main(void)
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
<h2><a class="header" href="#functions-table-1" id="functions-table-1">Functions Table</a></h2>
|
||||
<h2><a class="header" href="#functions-table-2" id="functions-table-2">Functions Table</a></h2>
|
||||
<table><thead><tr><th align="center">CMP</th><th align="center">CPY</th><th align="center">STR</th><th align="center">FREE</th><th align="center">HASH</th><th align="center">PRI</th></tr></thead><tbody>
|
||||
<tr><td align="center"><img src="https://placehold.it/20/9f3b94/000000?text=+" alt="#9f3b94" /></td><td align="center"><img src="https://placehold.it/20/9f3b94/000000?text=+" alt="#9f3b94" /></td><td align="center"><img src="https://placehold.it/20/497edd/000000?text=+" alt="#497edd" /></td><td align="center"><img src="https://placehold.it/20/00d3eb/000000?text=+" alt="#00d3eb" /></td><td align="center"><img src="https://placehold.it/20/2ef625/000000?text=+" alt="#2ef625" /></td><td align="center"><img src="https://placehold.it/20/2ef625/000000?text=+" alt="#2ef625" /></td></tr>
|
||||
</tbody></table>
|
||||
|
||||
Reference in new issue
Block a user