This section documents the map object of the GPAC framework.
More...
Detailed Description
- Note:
- The map use a random function for hashing. Collisions are resolved by using a GF_List on each slot.
Function Documentation
GF_Map* gf_map_new |
( |
u32 |
hash_capacity |
) |
|
Constructs a new map object
- Parameters:
-
| hash_capacity | the number of slot in the hash table |
- Note:
- a zero hash_capacity is not allowed, a hash_capacity of 1 is equivalent to a gf_list_find from GF_List with a complexity search in o(n)
- Returns:
- new map object
void gf_map_del |
( |
GF_Map * |
ptr |
) |
|
Destructs a map object
- Parameters:
-
| ptr | map object to destruct |
- Note:
- The caller is only responsible to destroy the content of the map, not the key
Constructs a new map iterator object
- Parameters:
-
| map | the map associated to the iterator |
| it | the resulting iterator |
- Returns:
- GF_OK if iterator has been properly generated, otherwiise a GF_Err
void gf_map_iter_del |
( |
GF_It_Map * |
ptr |
) |
|
Destructs a map iterator object
- Parameters:
-
| ptr | map iterator object to destruct |
void* gf_map_iter_has_next |
( |
GF_It_Map * |
it |
) |
|
Return the next value of a GF_Pair in the map
- Parameters:
-
| it | the map iterator object |
- Returns:
- the next value of the map if exists, otherwise NULL
GF_Err gf_map_iter_reset |
( |
GF_It_Map * |
it |
) |
|
Reinitalize the iterator to the beginning of the map
- Parameters:
-
| it | the map iterator object |
- Returns:
- GF_OK if the iterator has been correctly reinitialize, otherwise a GF_Err
u32 gf_map_count |
( |
const GF_Map * |
ptr |
) |
|
Returns number of items in the map
- Parameters:
-
- Returns:
- number of items in the map
GF_Err gf_map_insert |
( |
GF_Map * |
ptr, |
|
|
const char * |
key, |
|
|
void * |
item | |
|
) |
| | |
Adds an item in the map with an associated key
- Parameters:
-
| ptr | target map object |
| key | the identified key |
| item | item to add |
- Returns:
- GF_OF if insertion occurs properly, GF_NOT_SUPPORTED if the key already exists, a GF_Err in other cases
- Note:
- the caller is responsible for the deallocation of the key as it is copyied in the map
Bool gf_map_rem |
( |
GF_Map * |
ptr, |
|
|
const char * |
key | |
|
) |
| | |
Removes an item from the map given to its key if exists
- Parameters:
-
| ptr | target map object |
| key | the key of the item. |
- Returns:
- GF_TRUE if the key has been delete, otherwise GF_FALSE
- Note:
- It is the caller responsability to destroy the content of the list if needed
void* gf_map_find |
( |
GF_Map * |
ptr, |
|
|
const char * |
key | |
|
) |
| | |
Finds a key in the map
- Parameters:
-
| ptr | target map object. |
| key | the key to find. |
- Returns:
- a pointer to the corresponding value if found, otherwise NULL.
Bool gf_map_has_key |
( |
GF_Map * |
ptr, |
|
|
const char * |
key | |
|
) |
| | |
- Parameters:
-
| ptr | target map object. |
| key | the key to check. |
- Returns:
- GF_TRUE if map contains keys, otherwise GF_FALSE
void gf_map_reset |
( |
GF_Map * |
ptr |
) |
|
Resets the content of the map
- Parameters:
-
- Note:
- It is the caller responsability to destroy the content of the list if needed