cn_map / cn_map_at_rend

Syntax

CNM_BYTE cn_map_at_rend(CN_MAP map, CNM_ITERATOR * iterator)

Description

Checks if iterator is at the node before the first (lowest value) in the CN_Map map. Returns 1 if true. Returns 0 otherwise.

Return Value

Returns a unsigned char (typedef'd to cnm_byte).

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)
		);
	}
}