cn_map / cn_map_key_size

Syntax

CNM_UINT cn_map_key_size(CN_MAP map)

Description

Gives the size (in bytes) of the data type keys are stored in.

Return Value

Returns an unsigned integer (typedef'd as cnm_uint).

Examples

Basic Usage

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

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

void print_map_info(CN_MAP map) {
	printf(
		"%d %d\n",
		cn_map_key_size(map),
		cn_map_value_size(map)
	);
}

main() {
	//Make 3 maps with different types of keys and values.
	CN_MAP map_int  = cn_map_init(int        , int      , cn_cmp_int    );
	CN_MAP map_char = cn_map_init(char       , long long, cn_cmp_char   );
	CN_MAP map_ld   = cn_map_init(long double, short    , cn_cmp_ldouble);

	//Print out information about all three.
	print_map_info(map_int);
	print_map_info(map_char);
	print_map_info(map_ld);

	//Free all memory
	cn_map_free(map_int);
	cn_map_free(map_char);
	cn_map_free(map_ld);
}