Hash tables used to resolve legacy model identifiers.
More...
Go to the source code of this file.
|
| HTtable * | HTcreate (void) |
| | Allocate an empty case-insensitive identifier table.
|
| |
| int | HTinsert (HTtable *, char *, int) |
| | Prepend a key/data entry to a hash table without copying its key.
|
| |
| int | HTfind (HTtable *, const char *) |
| | Look up the most recently inserted case-insensitive key match.
|
| |
| char * | HTfindKey (HTtable *, const char *) |
| | Retrieve the original stored spelling of a case-insensitive key.
|
| |
| void | HTfree (HTtable *) |
| | Free all hash entries and the table bucket array.
|
| |
Hash tables used to resolve legacy model identifiers.
- Author
- Caleb Buahin caleb.nosp@m..bua.nosp@m.hin@g.nosp@m.mail.nosp@m..com (OpenSWMM maintenance and extensions)
- Copyright
- Copyright (c) 2026 Caleb Buahin. OpenSWMM contributions only; original EPA SWMM credits are retained.
- License
- Apache-2.0 for OpenSWMM contributions; original EPA SWMM provenance is retained.
◆ HTMAXSIZE
◆ NOTFOUND
◆ HTtable
◆ HTcreate()
Allocate an empty case-insensitive identifier table.
- Returns
- Owned zero-initialized HTMAXSIZE bucket array, or NULL on allocation failure.
- Note
- Release the table and its entries with HTfree(); key strings remain externally owned.
◆ HTfind()
| int HTfind |
( |
HTtable * | ht, |
|
|
const char * | key ) |
Look up the most recently inserted case-insensitive key match.
- Parameters
-
| [in] | ht | Non-null borrowed table created by HTcreate(). |
| [in] | key | Non-null borrowed nonempty null-terminated identifier. |
- Returns
- Stored integer value, or NOTFOUND if no entry matches.
- Note
- No storage is modified or retained; returned values can coincide with NOTFOUND if the caller inserted that sentinel as data.
◆ HTfindKey()
| char * HTfindKey |
( |
HTtable * | ht, |
|
|
const char * | key ) |
Retrieve the original stored spelling of a case-insensitive key.
- Parameters
-
| [in] | ht | Non-null borrowed table created by HTcreate(). |
| [in] | key | Non-null borrowed nonempty null-terminated lookup identifier. |
- Returns
- Borrowed original key pointer, or NULL if no entry matches.
- Note
- The pointer's lifetime follows the external key owner; the table does not copy, free or grant mutation rights to the stored identifier.
◆ HTfree()
Free all hash entries and the table bucket array.
- Parameters
-
| [in] | ht | Non-null exclusively owned table created by HTcreate(). |
- Postcondition
- Table and entry pointers are invalid; borrowed key strings are not freed. The caller must discard or reset its own ht pointer after this call.
◆ HTinsert()
| int HTinsert |
( |
HTtable * | ht, |
|
|
char * | key, |
|
|
int | data ) |
Prepend a key/data entry to a hash table without copying its key.
- Parameters
-
| [in,out] | ht | Non-null table created by HTcreate(). |
| [in] | key | Borrowed nonempty null-terminated identifier; it must remain alive and unchanged for the entry's lifetime. |
| [in] | data | Integer value associated with the identifier. |
- Returns
- One on insertion, zero on bucket/allocation failure.
- Note
- Duplicate keys are allowed and newest entries are found first. The table owns the entry allocation, but never frees key storage.