Typedefs | |
typedef cx_tree | cx_map |
The map datatype. | |
typedef cx_tree_iterator | cx_map_iterator |
The map iterator datatype. | |
typedef cx_tree_const_iterator | cx_map_const_iterator |
The map constant iterator datatype. | |
typedef cx_tree_compare_func | cx_map_compare_func |
The map's key comparison operator function. | |
Functions | |
cx_map_iterator | cx_map_begin (const cx_map *map) |
Get an iterator to the first pair in a map. | |
cx_map_iterator | cx_map_end (const cx_map *map) |
Get an iterator for the position after the last pair in the map. | |
cx_map_iterator | cx_map_next (const cx_map *map, cx_map_const_iterator position) |
Get an iterator for the next pair in the map. | |
cx_map_iterator | cx_map_previous (const cx_map *map, cx_map_const_iterator position) |
Get an iterator for the previous pair in the map. | |
void | cx_map_clear (cx_map *map) |
Remove all pairs from a map. | |
cxbool | cx_map_empty (const cx_map *map) |
Check whether a map is empty. | |
cx_map * | cx_map_new (cx_map_compare_func compare, cx_free_func key_destroy, cx_free_func value_destroy) |
Create a new map without any elements. | |
void | cx_map_delete (cx_map *map) |
Destroy a map and all its elements. | |
cxsize | cx_map_size (const cx_map *map) |
Get the actual number of pairs in the map. | |
cxsize | cx_map_max_size (const cx_map *map) |
Get the maximum number of pairs possible. | |
cx_map_compare_func | cx_map_key_comp (const cx_map *map) |
Retrieve a map's key comparison function. | |
void | cx_map_swap (cx_map *map1, cx_map *map2) |
Swap the contents of two maps. | |
cxptr | cx_map_assign (cx_map *map, cx_map_iterator position, cxcptr data) |
Assign data to an iterator position. | |
cxptr | cx_map_put (cx_map *map, cxcptr key, cxcptr data) |
Set the value of a pair matching the given key. | |
cxptr | cx_map_get_key (const cx_map *map, cx_map_const_iterator position) |
Get the key from a given iterator position. | |
cxptr | cx_map_get_value (const cx_map *map, cx_map_const_iterator position) |
Get the data from a given iterator position. | |
cxptr | cx_map_get (cx_map *map, cxcptr key) |
Get the data for a given key. | |
cx_map_iterator | cx_map_find (const cx_map *map, cxcptr key) |
Locate an element in the map. | |
cx_map_iterator | cx_map_lower_bound (const cx_map *map, cxcptr key) |
Find the beginning of a subsequence matching a given key. | |
cx_map_iterator | cx_map_upper_bound (const cx_map *map, cxcptr key) |
Find the end of a subsequence matching a given key. | |
void | cx_map_equal_range (const cx_map *map, cxcptr key, cx_map_iterator *begin, cx_map_iterator *end) |
Find a subsequence matching a given key. | |
cxsize | cx_map_count (const cx_map *map, cxcptr key) |
Get the number of elements matching a key. | |
cx_map_iterator | cx_map_insert (cx_map *map, cxcptr key, cxcptr data) |
Attempt to insert data into a map. | |
void | cx_map_erase_position (cx_map *map, cx_map_iterator position) |
Erase an element from a map. | |
void | cx_map_erase_range (cx_map *map, cx_map_iterator begin, cx_map_iterator end) |
Erase a range of elements from a map. | |
cxsize | cx_map_erase (cx_map *map, cxcptr key) |
Erase an element from a map according to the provided key. |
#include <cxmap.h>
typedef cx_tree cx_map |
The map datatype.
The internal representation of a map is a balanced binary tree. For this reason cx_map is just an alias for cx_tree.
The map's key comparison operator function.
This type of function is used internally by a map when key comparisons are necessary. It must return TRUE
if the comparison of its first argument with the second argument succeeds, and FALSE
otherwise. It is actually an alias for cx_tree_compare_func.
typedef cx_tree_const_iterator cx_map_const_iterator |
The map constant iterator datatype.
The map constant iterator is just an alias for the cx_tree_const_iterator datatype.
typedef cx_tree_iterator cx_map_iterator |
The map iterator datatype.
The map iterator is just an alias for the cx_tree_iterator datatype.
cxptr cx_map_assign | ( | cx_map * | map, | |
cx_map_iterator | position, | |||
cxcptr | data | |||
) |
Assign data to an iterator position.
map | A map. | |
position | Iterator positions where the data will be stored. | |
data | Data to store. |
cx_map_iterator cx_map_begin | ( | const cx_map * | map | ) |
Get an iterator to the first pair in a map.
map | The map to query. |
void cx_map_clear | ( | cx_map * | map | ) |
Remove all pairs from a map.
map | Map to be cleared. |
cxsize cx_map_count | ( | const cx_map * | map, | |
cxcptr | key | |||
) |
Get the number of elements matching a key.
map | A map. | |
key | Key of the (key, value) pair(s) to locate. |
void cx_map_delete | ( | cx_map * | map | ) |
Destroy a map and all its elements.
map | The map to destroy. |
cxbool cx_map_empty | ( | const cx_map * | map | ) |
Check whether a map is empty.
map | A map. |
TRUE
if the map is empty, and FALSE
otherwise.return (cx_map_size(map) == 0);
cx_map_iterator cx_map_end | ( | const cx_map * | map | ) |
Get an iterator for the position after the last pair in the map.
map | The map to query. |
void cx_map_equal_range | ( | const cx_map * | map, | |
cxcptr | key, | |||
cx_map_iterator * | begin, | |||
cx_map_iterator * | end | |||
) |
Find a subsequence matching a given key.
map | A map. | |
key | The key of the (key, value) pair(s) to be located. | |
begin | First element with key key. | |
end | Last element with key key. |
cxsize cx_map_erase | ( | cx_map * | map, | |
cxcptr | key | |||
) |
Erase an element from a map according to the provided key.
map | A map. | |
key | Key of the element to be erased. |
void cx_map_erase_position | ( | cx_map * | map, | |
cx_map_iterator | position | |||
) |
Erase an element from a map.
map | A map. | |
position | Iterator position of the element to be erased. |
void cx_map_erase_range | ( | cx_map * | map, | |
cx_map_iterator | begin, | |||
cx_map_iterator | end | |||
) |
Erase a range of elements from a map.
map | A map. | |
begin | Iterator pointing to the start of the range to erase. | |
end | Iterator pointing to the end of the range to erase. |
cx_map_iterator cx_map_find | ( | const cx_map * | map, | |
cxcptr | key | |||
) |
Locate an element in the map.
map | A map. | |
key | Key of the (key, value) pair to locate. |
cxptr cx_map_get | ( | cx_map * | map, | |
cxcptr | key | |||
) |
Get the data for a given key.
map | A map. | |
key | Key for which the data should be retrieved. |
NULL
as the associated default value, which is then returned.
cxptr cx_map_get_key | ( | const cx_map * | map, | |
cx_map_const_iterator | position | |||
) |
Get the key from a given iterator position.
map | A map. | |
position | Iterator position the data is retrieved from. |
cxptr cx_map_get_value | ( | const cx_map * | map, | |
cx_map_const_iterator | position | |||
) |
Get the data from a given iterator position.
map | A map. | |
position | Iterator position the data is retrieved from. |
cx_map_iterator cx_map_insert | ( | cx_map * | map, | |
cxcptr | key, | |||
cxcptr | data | |||
) |
Attempt to insert data into a map.
map | A map. | |
key | Key used to store the data. | |
data | Data to insert. |
NULL
if the pair could not be inserted.cx_map_compare_func cx_map_key_comp | ( | const cx_map * | map | ) |
Retrieve a map's key comparison function.
map | The map to query. |
cx_map_iterator cx_map_lower_bound | ( | const cx_map * | map, | |
cxcptr | key | |||
) |
Find the beginning of a subsequence matching a given key.
map | A map. | |
key | Key of the (key, value) pair(s) to locate. |
cxsize cx_map_max_size | ( | const cx_map * | map | ) |
Get the maximum number of pairs possible.
map | A map. |
cx_map* cx_map_new | ( | cx_map_compare_func | compare, | |
cx_free_func | key_destroy, | |||
cx_free_func | value_destroy | |||
) |
Create a new map without any elements.
compare | Function used to compare keys. | |
key_destroy | Destructor for the keys. | |
value_destroy | Destructor for the value field. |
The map's key comparison function is set to compare. It must return TRUE
or FALSE
if the comparison of the first argument passed to it with the second argument is found to be true or false respectively.
The destructors for a map node's key and value field are set to key_destroy and value_destroy. Whenever a map node is destroyed these functions are used to deallocate the memory used by the key and the value. Each of the destructors might be NULL
, i.e. keys and values are not deallocated during destroy operations.
cx_map_iterator cx_map_next | ( | const cx_map * | map, | |
cx_map_const_iterator | position | |||
) |
Get an iterator for the next pair in the map.
map | A map. | |
position | Current iterator position. |
cx_map_iterator cx_map_previous | ( | const cx_map * | map, | |
cx_map_const_iterator | position | |||
) |
Get an iterator for the previous pair in the map.
map | A map. | |
position | Current iterator position. |
cxptr cx_map_put | ( | cx_map * | map, | |
cxcptr | key, | |||
cxcptr | data | |||
) |
Set the value of a pair matching the given key.
map | A map. | |
key | The key of the map element to be changed. | |
data | Data value to be stored. |
cxsize cx_map_size | ( | const cx_map * | map | ) |
Get the actual number of pairs in the map.
map | A map. |
Swap the contents of two maps.
map1 | First map. | |
map2 | Second map. |
cx_map_iterator cx_map_upper_bound | ( | const cx_map * | map, | |
cxcptr | key | |||
) |
Find the end of a subsequence matching a given key.
map | A map. | |
key | Key of the (key, value) pair(s) to locate. |
cx_map_iterator it; it = cx_map_find(map, key); it = cx_map_next(map, it);