cn_map / cn_map_find

Syntax

void cn_map_find(CN_MAP map, CNM_ITERATOR * iterator, void * key)

Description

Performs a search in map for a key that matches key. If a node's key matches key, iterator will point to that node. Otherwise, it will point to the return value of cn_map_end.

You can check if this function failed by running cn_map_at_end on iterator. If that returns TRUE, the key wasn't found in map.

Return Value

Examples

Basic Usage

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

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

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

	char key   = 'd';
	int  value = 4;

	//Insert element into the map
	cn_map_insert(map, &key, &value);

	//Find 'd'
	CNM_ITERATOR it;
	cn_map_find(map, &it, &key);

	//Delete from the map
	cn_map_erase(map, &it);

	cn_map_free(map);
}