GPAC
Open Source Multimedia Framework. For more information, check out http://gpac.wp.mines-telecom.fr
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups

This section documents the map object of the GPAC framework. More...

+ Collaboration diagram for map:

Data Structures

struct  GF_Pair
 Pair structure. More...
 
struct  GF_It_Map
 
struct  GF_Map
 Map Object. More...
 
struct  GF_Iterator
 Map iterator Object. More...
 

Functions

GF_Mapgf_map_new (u32 hash_capacity)
 map constructor More...
 
void gf_map_del (GF_Map *ptr)
 map destructor More...
 
GF_Err gf_map_iter_set (GF_Map *map, GF_It_Map *it)
 Set a new map iterator. More...
 
void * gf_map_iter_has_next (GF_It_Map *it)
 return the next value in the map More...
 
GF_Err gf_map_iter_reset (GF_It_Map *it)
 Reset the iterator in the map. More...
 
u32 gf_map_count (const GF_Map *ptr)
 get count More...
 
GF_Err gf_map_insert (GF_Map *ptr, const char *key, void *item)
 add item More...
 
Bool gf_map_rem (GF_Map *ptr, const char *key)
 removes the couple key/item from the map More...
 
void * gf_map_find (GF_Map *ptr, const char *key)
 finds item More...
 
Bool gf_map_has_key (GF_Map *ptr, const char *key)
 Check if map contains key. More...
 
void gf_map_reset (GF_Map *ptr)
 resets map More...
 

Detailed Description

Note
The map use a random function for hashing. Collisions are resolved by using a GF_List on each slot.

Data Structure Documentation

struct GF_Pair

Define the association Key/value.

+ Collaboration diagram for GF_Pair:
Data Fields
char * key
void * value
struct GF_It_Map
+ Collaboration diagram for GF_It_Map:
Data Fields
GF_Map * map
GF_Pair * pair
u32 ilist
u32 hash
struct GF_Map

A GF_Map associate key to values.

+ Collaboration diagram for GF_Map:
struct GF_Iterator

Allows to go through each pair key/value in the map.

+ Collaboration diagram for GF_Iterator:

Function Documentation

GF_Map* gf_map_new ( u32  hash_capacity)

Constructs a new map object

Parameters
hash_capacitythe 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

+ Here is the call graph for this function:

void gf_map_del ( GF_Map ptr)

Destructs a map object

Parameters
ptrmap object to destruct
Note
The caller is only responsible to destroy the content of the map, not the key

+ Here is the call graph for this function:

GF_Err gf_map_iter_set ( GF_Map map,
GF_It_Map it 
)

Associate a map iterator to a map

Parameters
mapthe map associated to the iterator
itthe resulting iterator
Returns
GF_OK if iterator has been set properly, otherwise a GF_Err
void* gf_map_iter_has_next ( GF_It_Map it)
Return the next value of a GF_Pair in the map
\param it  the map iterator object
Returns
the next value of the map if exists, otherwise NULL

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

GF_Err gf_map_iter_reset ( GF_It_Map it)
Reinitalize the iterator to the beginning of the map
\param 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
ptrtarget map object
Returns
number of items in the map

+ Here is the call graph for this function:

GF_Err gf_map_insert ( GF_Map ptr,
const char *  key,
void *  item 
)

Adds an item in the map with an associated key

Parameters
ptrtarget map object
keythe identified key
itemitem 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

+ Here is the call graph for this function:

Bool gf_map_rem ( GF_Map ptr,
const char *  key 
)

Removes an item from the map given to its key if exists

Parameters
ptrtarget map object
keythe 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

+ Here is the call graph for this function:

void* gf_map_find ( GF_Map ptr,
const char *  key 
)

Finds a key in the map

Parameters
ptrtarget map object.
keythe key to find.
Returns
a pointer to the corresponding value if found, otherwise NULL.

+ Here is the call graph for this function:

Bool gf_map_has_key ( GF_Map ptr,
const char *  key 
)
Parameters
ptrtarget map object.
keythe key to check.
Returns
GF_TRUE if map contains keys, otherwise GF_FALSE

+ Here is the call graph for this function:

void gf_map_reset ( GF_Map ptr)

Resets the content of the map

Parameters
ptrtarget map object.
Note
It is the caller responsability to destroy the content of the list if needed

+ Here is the call graph for this function: