The Map Class
[The Classes]

A map to associate a key with a value. More...


Modules

 The Map Interface

Typedefs

typedef Cmaid_Container Cmaid_Map
 Type definition of the Map Class.

Functions

CMAID_INLINE void * cmaid_map_set (Cmaid_Map *m, void *key, void *data)
 Associates the given key with the give value.
CMAID_INLINE void cmaid_map_remove (Cmaid_Map *m, const void *key)
 Removes the key-value pair from the map.
CMAID_INLINE void * cmaid_map_get (Cmaid_Map *m, const void *key)
CMAID_INLINE void cmaid_map_value_iter_attach (Cmaid_Map *m, Cmaid_Iter *iter)
 Attaches an iterator to iterate over the values.


Detailed Description

A map to associate a key with a value.

The map class provides an interface to associate a key object with a value object. This is also known as associative array. The key needs to be unique, else you would get collisions, but the values maybe the same for two different keys.

The iterators attached with cmaid_container_iter_attach() function, iterate over the key values. To iterate over the values use the map function cmaid_map_value_iter_attach().


Function Documentation

CMAID_INLINE void* cmaid_map_get ( Cmaid_Map m,
const void *  key 
)

Parameters:
m The map to retrieve the value associated with the given key
key The key associated with the desired value
Returns:
Returns the value associated with the given key
This functions returns the value associated with the given key. If there is no value associated with it NULL will be returned.

CMAID_INLINE void cmaid_map_remove ( Cmaid_Map m,
const void *  key 
)

Removes the key-value pair from the map.

Parameters:
m The map to remove the key-value pair
key The key to remove
Returns:
Returns no value This functions removes the key-value pair from the map and frees if needed the memory of them. If the key is not part of the map nothing will happen.

CMAID_INLINE void* cmaid_map_set ( Cmaid_Map m,
void *  key,
void *  value 
)

Associates the given key with the give value.

Parameters:
m The map to associate key and value
key The key
value The data
Returns:
Returns the address of the saved key This functions associates the given key with the value. If there is not already a node, a new node will be added to the collection. If the key has already an entry in the collection the old value will be overwritten by the new value.

CMAID_INLINE void cmaid_map_value_iter_attach ( Cmaid_Map m,
Cmaid_Iter iter 
)

Attaches an iterator to iterate over the values.

Parameters:
m The map to attach the iterator
iter The iterator to attach
Returns:
Returns no value This function attaches an iterator to the map. Unlike the normal container iterator it will not iterate over the keys, but over the values of the map. To detach the iterator from the map use the container function cmaaid_container_iter_detach().


Generated on Wed Aug 5 00:20:50 2009 for Cmaid by  doxygen 1.5.8