6.5.3 Operations on Iterators

Map iterators support the following operations.

Function: int qsmm_is_iter_at_end (qsmm_iter_t iter)

This function returns a positive value if an iterator iter is a forward (normal) iterator addressing a location just after the last key-value pair in a mapping object, or if the iterator is a reverse iterator addressing a location just before the first key-value pair in a mapping object, or returns 0 otherwise. The function never returns negative values.

Function: int qsmm_iter_test_eq (qsmm_iter_t iter1, qsmm_iter_t iter2)

This function returns a positive value if iterators iter1 and iter2 address the same location in a mapping object, or returns 0 otherwise. The function never returns negative values.

Function: void qsmm_iter_next (qsmm_iter_t iter)

This function makes an iterator iter address the next key-value pair in a mapping object. If the iterator is a forward (normal) iterator, it addresses the next key-value pair in ascending order of keys. If the iterator is a reverse iterator, it addresses the next key-value pair in descending order of keys (i.e. the previous key-value pair in ascending order of keys).

Function: void qsmm_iter_prev (qsmm_iter_t iter)

This function makes an iterator iter address the previous key-value pair in a mapping object. If the iterator is a forward (normal) iterator, it addresses the previous key-value pair in ascending order of keys (i.e. the next key-value pair in descending order of keys). If the iterator is a reverse iterator, it addresses the previous key-value pair in descending order of keys (i.e. the next key-value pair in ascending order of keys).

Function: void qsmm_iter_assign (qsmm_iter_t dst, qsmm_iter_t src)

This function makes an iterator dst address the same location as an iterator src. The function also copies from src to dst the indicator whether an iterator is forward (normal) or reverse one. Either the function qsmm_map_iter_create or the function qsmm_map_multi_iter_create must have created both iterators.

Function: void qsmm_set_iter_val (qsmm_iter_t iter, void *valp)

This function sets to valp the value of a key-value pair addressed by an iterator iter and discards an old value. If values stored in key-value pair objects are untyped pointers, the function sets the untyped pointer equal to valp. If memory blocks of key-value pair objects contain memory blocks of values, and valp is not NULL, the function copies a memory block addressed by valp to the memory block of a value in the key-value pair object. If memory blocks of key-value pair objects contain memory blocks of values, and valp is NULL, the function zeroes the memory block of a value in the key-value pair object.

Function: void * qsmm_get_iter_key (qsmm_iter_t iter)

This function returns the key of a key-value pair addressed by an iterator iter. If keys stored in key-value pair objects are untyped pointers, the function returns such untyped pointer. If memory blocks of key-value pair objects contain memory blocks of keys, the function returns a pointer to the memory block of a key.

Function: void * qsmm_get_iter_val (qsmm_iter_t iter)

This function returns the value of a key-value pair addressed by an iterator iter. If values stored in key-value pair objects are untyped pointers, the function returns such untyped pointer. If memory blocks of key-value pair objects contain memory blocks of values, the function returns a pointer to the memory block of a value.