Go to the source code of this file.
◆ sm_insert
◆ SM_VAL
| #define SM_VAL |
( |
|
val | ) |
(val), sizeof(*val) |
◆ stringmap_entry_state_t
The state of a stringmap entry.
- Parameters
-
| EMPTY | The entry is empty. |
| OCCUPIED | The entry is occupied. |
| DEAD | The entry is dead. |
◆ stringmap_entry_t
A stringmap entry.
- Parameters
-
| key | The key of the entry. |
| value | The value of the entry. |
| state | The state of the entry. |
◆ stringmap_result_t
The result of a stringmap operation.
- Parameters
-
| CREATED | The entry was created. |
| UPDATED | The entry was updated. |
| NOT_FOUND | The entry was not found. |
| KILLED | The entry was killed. |
◆ stringmap_t
A stringmap.
- Parameters
-
| arena | The arena to allocate from. |
| entries | The entries of the stringmap. |
| capacity | The capacity of the stringmap. |
| count | The amount of entries in the stringmap. |
| dead_entries | The amount of dead entries of the stringmap. |
◆ stringmap_entry_state
The state of a stringmap entry.
- Parameters
-
| EMPTY | The entry is empty. |
| OCCUPIED | The entry is occupied. |
| DEAD | The entry is dead. |
| Enumerator |
|---|
| EMPTY | |
| OCCUPIED | |
| DEAD | |
◆ stringmap_result
The result of a stringmap operation.
- Parameters
-
| CREATED | The entry was created. |
| UPDATED | The entry was updated. |
| NOT_FOUND | The entry was not found. |
| KILLED | The entry was killed. |
| Enumerator |
|---|
| CREATED | |
| UPDATED | |
| NOT_FOUND | |
| KILLED | |
◆ __sm_insert()
Insert key and value into the stringmap.
Hashes and duplicates the key and sets the value, if the key already exists, it will be updated, if the capacity is too small, it will be automatically grown.
- Note
- This function is not meant to be run directly, and is called by the sm_ insert() macro.
- Parameters
-
| stringmap | The stringmap to insert into. |
| key | The key to insert. |
| value | The value to associate with the key. |
| vsize | The size of the value. |
- Precondition
stringmap and key must be valid and cannot be null.
value can't be null, as it would leave to a null dereference.
- Returns
- The result of the insert (which will be either CREATED or UPDATED in this case).
◆ sm_get()
Get a V from the stringmap.
Gets an entry from the stringmap, if the entry doesn't exist, it will be null.
- Parameters
-
| stringmap | The stringmap to get from. |
| key | The key to get. |
- Precondition
stringmap and key must be valid and cannot be null.
- Returns
- The value associated with the key, or null if it doesn't exist or is dead.
◆ sm_kill()
Remove / Kill entry at key from the stringmap.
Marks an entry as DEAD, if the key doesn't exist, it will return NOT_FOUND, otherwise it will return KILLED.
- Parameters
-
| stringmap | The stringmap to remove from. |
| key | The key to remove. |
- Precondition
stringmap and key must be valid and cannot be null.
- Returns
- The result of the remove (which will be either KILLED or NOT_FOUND in this case).
◆ sm_new()
Initializes a new stringmap.
Optionally use a nullable type for stringmaps.
With the capacity, and arena, if the given capacity is 0, it will use the built in default capacity, which is 16.
- Parameters
-
| arena | The arena to allocate from. |
| capacity | The capacity of the stringmap. |
- Precondition
arena must be valid and cannot be null.
- Returns
- A pointer to the new stringmap.