Go to the source code of this file.
Sparse Vector API.
This is a trimmed down sparse vector implementation tuned to the problem of 24-bit FC_IDs. In this case, the 24-bit index value is broken down in three 8-bit values. These values are used to index up to three 256 element arrays. Arrays are allocated, only when needed.
The lookup can complete in constant time (3 indexed array references).
A typical use case would be that the fabric/directory FC_IDs would cause two rows to be allocated, and the fabric assigned remote nodes would cause two rows to be allocated, with the root row always allocated. This gives five rows of 256 x sizeof(void*), resulting in 10k.
Definition in file spv.c.
Functions | |
| static void ** | spv_new_row (ocs_os_handle_t os, uint32_t rowcount) |
| Allocate a new sparse vector row. More... | |
| static void | _spv_del (ocs_os_handle_t os, void **a, uint32_t n, uint32_t depth) |
| Delete row recursively. More... | |
| void | spv_del (sparse_vector_t spv) |
| Delete a sparse vector. More... | |
| sparse_vector_t | spv_new (ocs_os_handle_t os) |
| Instantiate a new sparse vector object. More... | |
| static void * | spv_new_cell (sparse_vector_t sv, uint32_t idx, uint8_t alloc_new_rows) |
| Return the address of a cell. More... | |
| void | spv_set (sparse_vector_t sv, uint32_t idx, void *value) |
| Set the sparse vector cell value. More... | |
| void * | spv_get (sparse_vector_t sv, uint32_t idx) |
| Return the sparse vector cell value. More... | |