map
[utils]

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

Classes

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

Typedefs

typedef struct _tag_map GF_Map
typedef struct _it_map GF_It_Map

Functions

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

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
GF_Err gf_map_iter_set ( GF_Map map,
GF_It_Map it 
)

Associate a map iterator to a map

Parameters:
map the map associated to the iterator
it the 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

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:
ptr target map object
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:
ptr target map object.
Note:
It is the caller responsability to destroy the content of the list if needed

Generated on 10 Sep 2015 for libgpac by  doxygen 1.6.1