holoscan::pose_tree::HashMap
holoscan::pose_tree::HashMap
holoscan::pose_tree::HashMap
A hash map implementation using open addressing with linear probing.
This class provides a fixed-capacity hash map that uses pre-allocated memory and linear probing for collision resolution. It supports basic operations like insert, get, erase, and has. The hash map is designed for performance-critical scenarios where memory allocation should be minimized.
Template parameters
The key type for the hash map.
The value type for the hash map.
Default constructor used to be able to pre-allocate memory.
Reserve memory for the hash map.
Returns: Success or error status.
Parameters
Maximum number of elements the hash map can store.
Total capacity of the internal array (should be larger than size for efficiency).
Check if a key exists in the hash map.
Returns: True if the key exists, false otherwise.
Parameters
The key to search for.
Get the value associated with a key.
Returns: Value associated with the key on success, Error::kKeyNotFound if key doesn’t exist.
Parameters
The key to search for.
Try to get the value ptr associated with a key.
Returns: Value associated with the key on success, Error::kKeyNotFound if key doesn’t exist.
Parameters
The key to search for.
Insert a key-value pair into the hash map.
Returns: Success or error status. Error::kHashMapFull if the map is full, Error::kKeyAlreadyExists if the key already exists.
Parameters
The key to insert.
The value to associate with the key.
Remove a key-value pair from the hash map.
Returns: Success or error status. Error::kKeyNotFound if the key doesn’t exist.
Parameters
The key to remove.
Get the current number of elements in the hash map.
Returns: Current size of the hash map.
Get the capacity of the hash map.
Returns: Max capacity of the hash map.
Internal implementation for inserting key-value pairs.
Returns: Success or error status.
Parameters
The key to insert.
The value to associate with the key.
Fill holes in the hash table after deletion to maintain linear probing invariants.
This method is called after an element is deleted to ensure that subsequent lookups continue to work correctly with linear probing.
Parameters
The index where a deletion occurred.
Get the index where the key is.
Returns: The index associated with the key on success, Error::kKeyNotFound if key doesn’t exist.
Parameters
The key to search for.
Error codes used by this class.
Internal structure representing an entry in the hash map.