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.
Constructors
HashMap
Default constructor used to be able to pre-allocate memory.
Methods
initialize
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).
has
Check if a key exists in the hash map.
Returns: True if the key exists, false otherwise.
Parameters
The key to search for.
get
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_get
Mutable
Const
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
Single element (1)
Single element (2)
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.
erase
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.
size
Get the current number of elements in the hash map.
Returns: Current size of the hash map.
capacity
Get the capacity of the hash map.
Returns: Max capacity of the hash map.
insert_impl
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
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_index
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.
Types
Typedefs
Error
Error codes used by this class.
Member variables
Inner classes
Entry
Internal structure representing an entry in the hash map.