cn_map / cn_map_rbegin

Syntax

void cn_map_rbegin(CN_MAP map, CNM_ITERATOR * iterator)

Description

Sets iterator to point at the last node (highest value) in the CN_Map map.

Return Value

N/A

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_rbegin(map, &it); !cn_map_at_rend(map, &it); cn_map_prev(map, &it)) {
		printf(
			"%c -> %d\n",
			cn_map_iterator_key  (&it, char),
			cn_map_iterator_value(&it, int)
		);
	}
}