axl main logo
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Modules Pages
axlHashCursor* axl_hash_cursor_new ( axlHash hash)

Allows to get a cursor to iterate the hash in a linear and efficient way.

The axlHashCursor could be used to iterate an axlHash in an efficient way because it stores current state (position), hiding all module details. Then using the following functions you can modify the state (current position to get):

Finally, the following functions are provided to get the data stored at a particular position, pointed by the current status of the cursor:

You are allowed to remove elements from the hash (axlHash) having a cursor created (axlHashCursor), using axl_hash_cursor_remove.

Here is an example:

1 axlPointer key;
2 axlPointer value;
3 axlHashCursor * cursor;
4 
5 // create the cursor
6 cursor = axl_hash_cursor_new (hash);
7 
8 // while there are more elements
9 while (axl_hash_cursor_has_item (cursor)) {
10 
11  // get the value and key
12  value = axl_hash_cursor_get_key (cursor);
13  value = axl_hash_cursor_get_value (cursor);
14 
15  // get the next
16  axl_hash_cursor_next (cursor);
17 
18 }
19 
20 // free the cursor
21 axl_hash_cursor_free (cursor);
Parameters
hashThe hash that the new cursor (axlHashCursor) will provide access.
Returns
A newly created axlHashCursor used to iterate the hash. Once finished you must call to axl_hash_cursor_free.

References axl_new, axl_return_val_if_fail, and axl_true.

Referenced by axl_node_attr_cursor_new().