This section contains a hash map implementation.
More...
|
#define | ruMapPut(map, key, val) ruMapPutData(map, (ptr)(key), (ptr)(val), NULL) |
| Runs ruMapPutData with ptr casts. More...
|
|
#define | ruMapTryPut(map, key, val, existing) ruMapPutData(map, (ptr)(key), (ptr)(val), (ptr*)(existing)) |
| Runs ruMapPutData with ptr casts. More...
|
|
#define | ruMapRemove(rm, key, val) ruMapRemoveData(rm, (trans_ptr)(key), (ptr*)(val)) |
| Runs ruMapRemoveData with ptr casts. More...
|
|
#define | ruMapGet(rm, key, val) ruMapGetValue(rm, (trans_ptr)(key), (ptr*)(val)) |
| Runs ruMapGetValue with a ptr cast. More...
|
|
#define | ruMapHas(rm, key, code) ruMapHasKey(rm, (trans_ptr)(key), code) |
| Runs ruMapHasKey with a ptr casted key. More...
|
|
#define | ruMapFirst(rm, key, value) ruMapFirstSet(rm, (ptr*)(key), (ptr*)(value)) |
| Runs ruMapFirstSet with ptr casts. More...
|
|
#define | ruMapNext(rm, key, value) ruMapNextSet(rm, (ptr*)(key), (ptr*)(value)) |
| Runs ruMapNextSet with ptr casts. More...
|
|
|
typedef void * | ruMap |
| An opaque type representing a map object. More...
|
|
|
RUAPI ruMap | ruMapNew (ruType keyType, ruType valueType) |
| Creates a new ruMap based on the given specifications. More...
|
|
RUAPI ruMap | ruMapFree (ruMap rm) |
| Frees the given map and its members. More...
|
|
RUAPI int32_t | ruMapPutData (ruMap rm, ptr key, ptr val, ptr *exisitingVal) |
| Insert a key/val pair into the map. More...
|
|
RUAPI int32_t | ruMapRemoveData (ruMap rm, trans_ptr key, ptr *val) |
| Removes an entry from the map. More...
|
|
RUAPI int32_t | ruMapRemoveAll (ruMap rm) |
| Removes all entries from the map. More...
|
|
RUAPI int32_t | ruMapGetValue (ruMap rm, trans_ptr key, ptr *val) |
| Retrieves an pointer entry from the map. More...
|
|
RUAPI bool | ruMapHasKey (ruMap rm, trans_ptr key, int32_t *code) |
| Tests whether map has an entry for given key. More...
|
|
RUAPI int32_t | ruMapFirstSet (ruMap rm, ptr *key, ptr *value) |
| Initializes a map iterator and populates given parameters with the first key pair to serve as a for loop initializer. More...
|
|
RUAPI int32_t | ruMapNextSet (ruMap rm, ptr *key, ptr *value) |
| Retrieves the next key/value pair from the map. More...
|
|
RUAPI int32_t | ruMapKeyList (ruMap rm, ruList *keys) |
| Return a key list of the given map. More...
|
|
RUAPI uint32_t | ruMapSize (ruMap rm, int32_t *code) |
| Returns the size of the map. More...
|
|
This section contains a hash map implementation.
◆ ruMapFirst
Runs ruMapFirstSet with ptr casts.
Example:
int ret;
void *key = NULL, *val = NULL;
}
#define ruMapFirst(rm, key, value)
Runs ruMapFirstSet with ptr casts.
Definition: map.h:194
#define ruMapNext(rm, key, value)
Runs ruMapNextSet with ptr casts.
Definition: map.h:215
#define RUE_OK
Definition: errors.h:66
NOTE: Either key or value must be set.
- Parameters
-
rm | The map to iterate over. |
key | Where to store the current key. (optional) |
value | Where to store the current value. (optional) |
- Returns
- RUE_OK on success RUE_FILE_NOT_FOUND at the end of the set RUE_USER_ABORT when a threaded map has quit else a regify error code.
◆ ruMapGet
◆ ruMapHas
Runs ruMapHasKey with a ptr casted key.
- Parameters
-
rm | The map to check. |
key | The key to be searched. |
code | (Optional) Stores RUE_OK on success RUE_USER_ABORT when a threaded map has quit else a regify error code. |
- Returns
- true if key exists or false on error or if not.
◆ ruMapNext
◆ ruMapPut
Runs ruMapPutData with ptr casts.
- Parameters
-
map | Map to insert key / value pair into. |
key | The key to insert. For numeric specs this must be an address to the underlying variable. |
val | The associated value to go with the key. For numeric specs this must be an address to the underlying variable. |
- Returns
- RUE_OK on success RUE_USER_ABORT when a threaded map has quit else a regify error code.
◆ ruMapRemove
Runs ruMapRemoveData with ptr casts.
- Parameters
-
rm | The map to remove the entry from. |
key | The key to be removed. |
val | (Optional) Where to store the retrieved value associated with the key. |
- Returns
- RUE_OK on success RUE_USER_ABORT when a threaded map has quit else a regify error code.
◆ ruMapTryPut
#define ruMapTryPut |
( |
|
map, |
|
|
|
key, |
|
|
|
val, |
|
|
|
existing |
|
) |
| ruMapPutData(map, (ptr)(key), (ptr)(val), (ptr*)(existing)) |
Runs ruMapPutData with ptr casts.
- Parameters
-
map | Map to insert key / value pair into. |
key | The key to insert. |
val | The associated value to go with the key. |
existing | Optional. If set the pointer to the associated existing value will be stored here, and key/value will not be updated. |
- Returns
- RUE_OK on success, RUE_FILE_EXISTS if exisitingVal was set and there was one, RUE_USER_ABORT when a threaded map has quit else a regify error code.
◆ ruMap
An opaque type representing a map object.
◆ ruMapFirstSet()
RUAPI int32_t ruMapFirstSet |
( |
ruMap |
rm, |
|
|
ptr * |
key, |
|
|
ptr * |
value |
|
) |
| |
Initializes a map iterator and populates given parameters with the first key pair to serve as a for loop initializer.
NOTE: Either key or value must be set.
- Parameters
-
rm | The map to iterate over. |
key | Where to store the current key. (optional) |
value | Where to store the current value. (optional) |
- Returns
- RUE_OK on success RUE_FILE_NOT_FOUND at the end of the set RUE_USER_ABORT when a threaded map has quit else a regify error code.
◆ ruMapFree()
Frees the given map and its members.
- Parameters
-
- Returns
- NULL
◆ ruMapGetValue()
Retrieves an pointer entry from the map.
- Parameters
-
rm | The map to retrieve the entry from. |
key | The key to be retrieved. |
val | Where to store the retrieved value associated with the key. |
- Returns
- RUE_OK on success RUE_GENERAL if key was not found RUE_USER_ABORT when a threaded map has quit else a regify error code.
◆ ruMapHasKey()
Tests whether map has an entry for given key.
- Parameters
-
rm | The map to check. |
key | The key to be searched. |
code | (Optional) Stores RUE_OK on success RUE_USER_ABORT when a threaded map has quit else a regify error code. |
- Returns
- true if key exists or false on error or if not.
◆ ruMapKeyList()
Return a key list of the given map.
- Parameters
-
rm | The map to get the key list from. |
keys | Where to store the resulting list. |
- Returns
- RUE_OK on success, RUE_USER_ABORT when a threaded map has quit else a regify error code.
◆ ruMapNew()
Creates a new ruMap based on the given specifications.
- Parameters
-
keyType | A key specification. Will be freed by this call. |
valueType | A value specification. Will be freed by this call. |
- Returns
- Newly create map. Caller m ust free with ruMapFree.
◆ ruMapNextSet()
RUAPI int32_t ruMapNextSet |
( |
ruMap |
rm, |
|
|
ptr * |
key, |
|
|
ptr * |
value |
|
) |
| |
Retrieves the next key/value pair from the map.
NOTE: Either key or value must be set.
- Parameters
-
rm | The map to retrieve the entry from. |
key | Where to store the current key. (optional) |
value | Where to store the current value. (optional) |
- Returns
- RUE_OK on success, RUE_FILE_NOT_FOUND at the end of the set RUE_INVALID_STATE if ruMapFirstSet hasn't been called or been invalidated. RUE_USER_ABORT when a threaded map has quit else a regify error code.
◆ ruMapPutData()
RUAPI int32_t ruMapPutData |
( |
ruMap |
rm, |
|
|
ptr |
key, |
|
|
ptr |
val, |
|
|
ptr * |
exisitingVal |
|
) |
| |
Insert a key/val pair into the map.
- Parameters
-
rm | Map to insert key / value pair into. |
key | The key to insert. For numeric specs this must be an address to the underlying variable. |
val | The associated value to go with the key. For numeric specs this must be an address to the underlying variable. |
exisitingVal | Optional. If set the pointer to the associated existing value will be stored here, and key/value will not be updated. |
- Returns
- RUE_OK on success, RUE_FILE_EXISTS if exisitingVal was set and there was one, RUE_USER_ABORT when a threaded map has quit else a regify error code.
◆ ruMapRemoveAll()
RUAPI int32_t ruMapRemoveAll |
( |
ruMap |
rm | ) |
|
Removes all entries from the map.
- Parameters
-
rm | The map to remove the entry from. |
- Returns
- RUE_OK on success RUE_USER_ABORT when a threaded map has quit else a regify error code.
◆ ruMapRemoveData()
Removes an entry from the map.
- Parameters
-
rm | The map to remove the entry from. |
key | The key to be removed. |
val | (Optional) Where to store the retrieved value associated with the key. |
- Returns
- RUE_OK on success RUE_USER_ABORT when a threaded map has quit else a regify error code.
◆ ruMapSize()
RUAPI uint32_t ruMapSize |
( |
ruMap |
rm, |
|
|
int32_t * |
code |
|
) |
| |
Returns the size of the map.
- Parameters
-
rm | Map to return the size of. |
code | (Optional) Stores RUE_OK on success or regify error code. |
- Returns
- Size of the map or 0 on error.