<trclass="memdesc:"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Single key/value slot used internally by the open-addressing hash map. <ahref="structkv__pair__t.html#details">More...</a><br/></td></tr>
<trclass="memdesc:"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Minimal open-addressing hash map for 64-bit key/value pairs used in deduplication lookup. <ahref="structhash__map__t.html#details">More...</a><br/></td></tr>
<trclass="memdesc:a4698f62d88ee9530fb93bf672455676f"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Creates a new hash map with the specified initial size. <br/></td></tr>
<trclass="memdesc:ab885e8c5bedaf6f3cca1877e378fd04f"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Frees all memory associated with a hash map. <br/></td></tr>
<trclass="memdesc:a56a11edd19b5362f1dd719a11c06f892"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Inserts a key-value pair into the hash map. <br/></td></tr>
<trclass="memdesc:a0719b4ee8aaa73765678b6b1db733fcd"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Looks up a value by key in the hash map. <br/></td></tr>
<p>Creates a new hash map with the specified initial size. </p>
<p>Allocates and initializes a new hash map structure with the given size. The hash map uses open addressing with linear probing for collision resolution. The table is zero-initialized, making empty slots identifiable by having a key value of 0.</p>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">size</td><td>Initial size of the hash table. Must be greater than 0.</td></tr>
</table>
</dd>
</dl>
<dlclass="section return"><dt>Returns</dt><dd>Returns a pointer to the newly created hash map, or NULL if allocation fails. </dd></dl>
<dlclass="retval"><dt>Return values</dt><dd>
<tableclass="retval">
<tr><tdclass="paramname">hash_map_t*</td><td>Successfully created hash map with:<ul>
<li>Allocated and zero-initialized table of specified size</li>
<dlclass="section note"><dt>Note</dt><dd>The caller is responsible for freeing the returned hash map using <aclass="el"href="hash__map_8c.html#ab885e8c5bedaf6f3cca1877e378fd04f"title="Frees all memory associated with a hash map.">free_map()</a>. </dd>
<dd>
A key value of 0 is reserved to indicate empty slots and cannot be used as a valid key.</dd></dl>
<dlclass="section see"><dt>See also</dt><dd><aclass="el"href="hash__map_8c.html#ab885e8c5bedaf6f3cca1877e378fd04f"title="Frees all memory associated with a hash map.">free_map()</a></dd></dl>
<pclass="definition">Definition at line <aclass="el"href="hash__map_8c_source.html#l00049">49</a> of file <aclass="el"href="hash__map_8c_source.html">hash_map.c</a>.</p>
<pclass="reference">References <aclass="el"href="hash__map_8h_source.html#l00053">hash_map_t::count</a>, <aclass="el"href="hash__map_8h_source.html#l00052">hash_map_t::size</a>, and <aclass="el"href="hash__map_8h_source.html#l00051">hash_map_t::table</a>.</p>
<pclass="reference">Referenced by <aclass="el"href="create_8c_source.html#l00279">aaruf_create()</a>, and <aclass="el"href="open_8c_source.html#l00223">aaruf_open()</a>.</p>
<p>Frees all memory associated with a hash map. </p>
<p>Deallocates the hash table and the hash map structure itself. After calling this function, the hash map pointer becomes invalid and should not be used.</p>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">map</td><td>Pointer to the hash map to free. Can be NULL (no operation performed).</td></tr>
</table>
</dd>
</dl>
<dlclass="section note"><dt>Note</dt><dd>This function does not free any memory pointed to by the values stored in the map. If the values are dynamically allocated, they must be freed separately before calling this function.</dd></dl>
<dlclass="section see"><dt>See also</dt><dd><aclass="el"href="hash__map_8c.html#a4698f62d88ee9530fb93bf672455676f"title="Creates a new hash map with the specified initial size.">create_map()</a></dd></dl>
<pclass="definition">Definition at line <aclass="el"href="hash__map_8c_source.html#l00073">73</a> of file <aclass="el"href="hash__map_8c_source.html">hash_map.c</a>.</p>
<pclass="reference">Referenced by <aclass="el"href="close_8c_source.html#l04059">aaruf_close()</a>, and <aclass="el"href="create_8c_source.html#l00030">cleanup_failed_create()</a>.</p>
<p>Inserts a key-value pair into the hash map. </p>
<p>Adds a new key-value pair to the hash map using open addressing with linear probing for collision resolution. If the key already exists, the insertion fails and returns false. The function automatically resizes the hash table when the load factor exceeds the threshold (0.75) to maintain optimal performance.</p>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">map</td><td>Pointer to the hash map. Must not be NULL. </td></tr>
<tr><tdclass="paramname">key</td><td>The key to insert. Must not be 0 as this value is reserved for empty slots. </td></tr>
<tr><tdclass="paramname">value</td><td>The value to associate with the key.</td></tr>
</table>
</dd>
</dl>
<dlclass="section return"><dt>Returns</dt><dd>Returns the result of the insertion operation. </dd></dl>
<dlclass="retval"><dt>Return values</dt><dd>
<tableclass="retval">
<tr><tdclass="paramname">true</td><td>Successfully inserted the key-value pair. The map count is incremented. </td></tr>
<tr><tdclass="paramname">false</td><td>Key already exists in the map. No changes made to the map.</td></tr>
</table>
</dd>
</dl>
<dlclass="section note"><dt>Note</dt><dd>If insertion would exceed the load factor threshold, the hash table is automatically resized to twice its current size before insertion. </dd>
<dd>
Time complexity: O(1) average case, O(n) worst case with poor hash distribution. </dd>
<dd>
Space complexity: O(1) unless resizing occurs, in which case it's O(n).</dd></dl>
<dlclass="section warning"><dt>Warning</dt><dd>Using 0 as a key value will result in undefined behavior as 0 is reserved for marking empty slots. </dd>
<dd>
If memory allocation fails during automatic resizing, the program may terminate.</dd></dl>
<dlclass="section see"><dt>See also</dt><dd><aclass="el"href="hash__map_8c.html#a0719b4ee8aaa73765678b6b1db733fcd"title="Looks up a value by key in the hash map.">lookup_map()</a></dd>
<dd>
<aclass="el"href="hash__map_8c.html#ad662d4309e791d854bc7a788b1cddf34"title="Resizes the hash map to a new size and rehashes all entries.">resize_map()</a></dd></dl>
<pclass="definition">Definition at line <aclass="el"href="hash__map_8c_source.html#l00153">153</a> of file <aclass="el"href="hash__map_8c_source.html">hash_map.c</a>.</p>
<pclass="reference">References <aclass="el"href="hash__map_8h_source.html#l00053">hash_map_t::count</a>, <aclass="el"href="hash__map_8h_source.html#l00034">kv_pair_t::key</a>, <aclass="el"href="hash__map_8c_source.html#l00026">LOAD_FACTOR</a>, <aclass="el"href="hash__map_8c_source.html#l00101">resize_map()</a>, <aclass="el"href="hash__map_8h_source.html#l00052">hash_map_t::size</a>, <aclass="el"href="hash__map_8h_source.html#l00051">hash_map_t::table</a>, and <aclass="el"href="hash__map_8h_source.html#l00035">kv_pair_t::value</a>.</p>
<pclass="reference">Referenced by <aclass="el"href="write_8c_source.html#l00098">aaruf_write_sector()</a>.</p>
<p>Searches for the specified key in the hash map and retrieves its associated value. Uses linear probing to handle collisions during the search. The function does not modify the hash map in any way.</p>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">map</td><td>Pointer to the hash map to search. Must not be NULL. </td></tr>
<tr><tdclass="paramname">key</td><td>The key to search for. Must not be 0. </td></tr>
<tr><tdclass="paramname">out_value</td><td>Pointer to store the found value. Must not be NULL. Only modified if the key is found.</td></tr>
</table>
</dd>
</dl>
<dlclass="section return"><dt>Returns</dt><dd>Returns whether the key was found in the map. </dd></dl>
<dlclass="retval"><dt>Return values</dt><dd>
<tableclass="retval">
<tr><tdclass="paramname">true</td><td>Key found. The associated value is written to *out_value. </td></tr>
<tr><tdclass="paramname">false</td><td>Key not found. *out_value is not modified.</td></tr>
</table>
</dd>
</dl>
<dlclass="section note"><dt>Note</dt><dd>Time complexity: O(1) average case, O(n) worst case with poor hash distribution or high load factor. </dd>
<dd>
The function is read-only and does not modify the hash map structure. </dd>
<dd>
Searching for key value 0 will always return false as 0 indicates empty slots.</dd></dl>
<dlclass="section warning"><dt>Warning</dt><dd>The out_value parameter must point to valid memory location. Passing NULL will result in undefined behavior.</dd></dl>
<dlclass="section see"><dt>See also</dt><dd><aclass="el"href="hash__map_8c.html#a56a11edd19b5362f1dd719a11c06f892"title="Inserts a key-value pair into the hash map.">insert_map()</a></dd></dl>
<pclass="definition">Definition at line <aclass="el"href="hash__map_8c_source.html#l00196">196</a> of file <aclass="el"href="hash__map_8c_source.html">hash_map.c</a>.</p>
<pclass="reference">References <aclass="el"href="hash__map_8h_source.html#l00034">kv_pair_t::key</a>, <aclass="el"href="hash__map_8h_source.html#l00052">hash_map_t::size</a>, <aclass="el"href="hash__map_8h_source.html#l00051">hash_map_t::table</a>, and <aclass="el"href="hash__map_8h_source.html#l00035">kv_pair_t::value</a>.</p>
<pclass="reference">Referenced by <aclass="el"href="write_8c_source.html#l00098">aaruf_write_sector()</a>.</p>
</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<divid="page-nav"class="page-nav-panel">
<divid="page-nav-resize-handle"></div>
<divid="page-nav-tree">
<divid="page-nav-contents">
</div><!-- page-nav-contents -->
</div><!-- page-nav-tree -->
</div><!-- page-nav -->
</div><!-- container -->
<!-- start footer part -->
<divid="nav-path"class="navpath"><!-- id is needed for treeview function! -->
<liclass="footer">Generated by <ahref="https://www.doxygen.org/index.html"><imgclass="footer"src="doxygen.svg"width="104"height="31"alt="doxygen"/></a> 1.14.0 </li>