|
libsnobol4 1.0.2
High-performance SNOBOL4-style pattern matching library
|
Runtime-owned sparse array objects for SNOBOL4. More...


Go to the source code of this file.
Classes | |
| struct | array_entry |
| A single entry in the sparse array. More... | |
| struct | snobol_array |
| Sparse array state. More... | |
Macros | |
| #define | ARRAY_INITIAL_CAPACITY 16 |
| Initial capacity for a new array. | |
Typedefs | |
| typedef struct array_entry | array_entry_t |
| A single entry in the sparse array. | |
| typedef struct snobol_array | snobol_array_t |
| Sparse array state. | |
Functions | |
| snobol_array_t * | snobol_array_create (int32_t bounds_hint) |
| Create a new sparse array. | |
| snobol_array_t * | snobol_array_retain (snobol_array_t *array) |
| Retain (increment refcount) an array. | |
| void | snobol_array_release (snobol_array_t *array) |
| Release (decrement refcount) an array; frees when refcount reaches 0. | |
| bool | snobol_array_set (snobol_array_t *array, int32_t key, const char *value) |
| Set a value at the given key. | |
| const char * | snobol_array_get (const snobol_array_t *array, int32_t key) |
| Get the value at a given key. | |
| bool | snobol_array_set_ex (snobol_array_t *array, int32_t key, const char *value, size_t value_len) |
| Set a value at the given key (NUL-safe byte-exact variant). | |
| const char * | snobol_array_get_ex (const snobol_array_t *array, int32_t key, size_t *out_len) |
| Get the value at a given key (NUL-safe). | |
| bool | snobol_array_has (const snobol_array_t *array, int32_t key) |
| Check whether a key has an active entry. | |
| bool | snobol_array_delete (snobol_array_t *array, int32_t key) |
| Delete the entry at a given key (marks as tombstone). | |
| void | snobol_array_clear (snobol_array_t *array) |
| Clear all entries from the array (resets to empty). | |
| size_t | snobol_array_size (const snobol_array_t *array) |
| Return the number of active entries. | |
| int32_t * | snobol_array_keys (const snobol_array_t *array, size_t *out_count) |
| Get all active keys. | |
| char ** | snobol_array_values (const snobol_array_t *array, size_t *out_count) |
| Get all active values. | |
Runtime-owned sparse array objects for SNOBOL4.
Provides an integer-keyed sparse array with get/set/delete/size operations. Arrays use reference counting for safe sharing across pattern executions. Keys are int32_t; values are strings (copied on insert).
Ownership/Lifetime Rules:
Definition in file array.h.
| #define ARRAY_INITIAL_CAPACITY 16 |
| typedef struct array_entry array_entry_t |
A single entry in the sparse array.
| typedef struct snobol_array snobol_array_t |
Sparse array state.
| void snobol_array_clear | ( | snobol_array_t * | array | ) |
Clear all entries from the array (resets to empty).
| array | Target array. |
| snobol_array_t * snobol_array_create | ( | int32_t | bounds_hint | ) |
Create a new sparse array.
| bounds_hint | Expected key range hint (may be 0). |
| bool snobol_array_delete | ( | snobol_array_t * | array, |
| int32_t | key ) |
Delete the entry at a given key (marks as tombstone).
| array | Target array. |
| key | Integer key. |
| const char * snobol_array_get | ( | const snobol_array_t * | array, |
| int32_t | key ) |
Get the value at a given key.
| array | Target array. |
| key | Integer key. |
| const char * snobol_array_get_ex | ( | const snobol_array_t * | array, |
| int32_t | key, | ||
| size_t * | out_len ) |
Get the value at a given key (NUL-safe).
| array | Target array. |
| key | Integer key. |
| out_len | Set to the byte length of the returned value (may be NULL). |
| bool snobol_array_has | ( | const snobol_array_t * | array, |
| int32_t | key ) |
Check whether a key has an active entry.
| array | Target array. |
| key | Integer key. |
| int32_t * snobol_array_keys | ( | const snobol_array_t * | array, |
| size_t * | out_count ) |
Get all active keys.
| array | Target array. |
| out_count | Set to the number of keys returned. |
| void snobol_array_release | ( | snobol_array_t * | array | ) |
Release (decrement refcount) an array; frees when refcount reaches 0.
| array | Array to release (NULL is safe). |
| snobol_array_t * snobol_array_retain | ( | snobol_array_t * | array | ) |
Retain (increment refcount) an array.
| array | Array to retain. |
| bool snobol_array_set | ( | snobol_array_t * | array, |
| int32_t | key, | ||
| const char * | value ) |
Set a value at the given key.
| array | Target array. |
| key | Integer key. |
| value | NUL-terminated string value (copied internally). |
| bool snobol_array_set_ex | ( | snobol_array_t * | array, |
| int32_t | key, | ||
| const char * | value, | ||
| size_t | value_len ) |
Set a value at the given key (NUL-safe byte-exact variant).
| array | Target array. |
| key | Integer key. |
| value | String value (copied internally), or NULL to delete. |
| value_len | Byte length of value (may contain NULs). |
| size_t snobol_array_size | ( | const snobol_array_t * | array | ) |
Return the number of active entries.
| array | Target array. |
| char ** snobol_array_values | ( | const snobol_array_t * | array, |
| size_t * | out_count ) |
Get all active values.
| array | Target array. |
| out_count | Set to the number of values returned. |