Declaration of the MapOfInt structure and supporting functions for managing a map of integers keyed by a string. More...
#include "uintarray.h"
Go to the source code of this file.
Classes | |
struct | MapOfIntEntry |
Represents an association between a string and an integer. More... | |
struct | MapOfInt |
Represents a list of MapOfIntEntry objects that maps a string to an integer value. Call MapOfInt_Initialize() to initialize the MapOfInt structure and call MapOfInt_Clear() to release the memory of the structure. More... | |
Macros | |
#define | __MAPOFINTS_H__ |
Functions | |
void | MapOfInt_Initialize (MapOfInt *map) |
Initialize the given MapOfInt structure so it is ready for use. | |
void | MapOfInt_Clear (MapOfInt *map) |
Clear the given MapOfInt object, releasing all memory associated with it. Leaves the object in an initialize state to be reused, if desired. | |
bool | MapOfInt_Add (MapOfInt *map, const char *key, int value) |
Add a key/value association to the given MapOfInt object. The MapOfInt object takes ownership of the key and value arguments and will free them when MapOfInt_Clear() is called in the object. | |
int | MapOfInt_Find (MapOfInt *map, const char *key) |
Find the specified key in the given MapOfInt object, returning an index into the object. | |
Declaration of the MapOfInt structure and supporting functions for managing a map of integers keyed by a string.
Definition in file mapofint.h.
#define __MAPOFINTS_H__ |
Definition at line 8 of file mapofint.h.
bool MapOfInt_Add | ( | MapOfInt * | map, |
const char * | key, | ||
int | value | ||
) |
Add a key/value association to the given MapOfInt object. The MapOfInt object takes ownership of the key and value arguments and will free them when MapOfInt_Clear() is called in the object.
map | The MapOfInt object to add to. |
key | The key value to be added. This must be allocated, directly or indirectly, with malloc() as it will be freed when the MapOfInt object is cleared. |
value | The integer being mapped to the key. |
Definition at line 40 of file mapofint.c.
References MapOfInt::entries, MapOfInt::entries_count, MapOfIntEntry::key, and MapOfIntEntry::value.
Referenced by Shop_AddItemToInventory().
void MapOfInt_Clear | ( | MapOfInt * | map | ) |
Clear the given MapOfInt object, releasing all memory associated with it. Leaves the object in an initialize state to be reused, if desired.
map | The MapOfInt object to clear. |
Definition at line 28 of file mapofint.c.
References MapOfInt::entries, and MapOfInt_Initialize().
Referenced by Shop_Destroy().
int MapOfInt_Find | ( | MapOfInt * | map, |
const char * | key | ||
) |
Find the specified key in the given MapOfInt object, returning an index into the object.
map | The MapOfInt object to search. |
key | The key to search for. |
Definition at line 72 of file mapofint.c.
References MapOfInt::entries, MapOfInt::entries_count, and MapOfIntEntry::key.
Referenced by Shop_AddItemToInventory(), Shop_IsItemInStock(), and Shop_PickupOrder().
void MapOfInt_Initialize | ( | MapOfInt * | map | ) |
Initialize the given MapOfInt structure so it is ready for use.
Alternatively, declare the MapOfInt instance like this:
map | The MapOfInt object to initialize. |
Definition at line 16 of file mapofint.c.
References MapOfInt::entries, and MapOfInt::entries_count.
Referenced by MapOfInt_Clear(), and Shop_Create().