cn_map / cn_map_iterator_value

Syntax

value_type cn_map_iterator_value(CNM_ITERATOR * iterator, datatype value_type)

Description

Gets the value from iterator and casts it to type value_type. This is treated as an immediate value, and can be used to directly access a value in the CN_Map and modify it.

Return Value

Examples

Basic Usage

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "cn_cmp.h"
#include "cn_map.h"

main() {
	CN_MAP map = cn_map_init(char, int, cn_cmp_char);

	char key;
	int  value;

	//Put in a-z with 0-25 in as key/value pairs.
	for (key = 'a', value = 0; key <= 'z'; key++, value++) {
		cn_map_insert(map, &key, &value);
	}

	//Iterate through
	CNM_ITERATOR it;

	for (cn_map_begin(map, &it); !cn_map_at_end(map, &it); cn_map_next(map, &it)) {
		printf(
			"%c -> %d\n",
			cn_map_iterator_key  (&it, char),
			cn_map_iterator_value(&it, int)
		);
	}
}