Logo

Programming-Idioms

History of Idiom 8 > diff from v58 to v59

Edit summary for version 59 by phrank:
New C implementation by user [phrank]

Version 58

2019-09-26, 22:32:17

Version 59

2019-09-27, 19:28:17

Idiom #8 Initialize a new map (associative array)

Declare a new map object x, and provide some (key, value) pairs as initial content.

Idiom #8 Initialize a new map (associative array)

Declare a new map object x, and provide some (key, value) pairs as initial content.

Extra Keywords
table dictionary hash
Extra Keywords
table dictionary hash
Imports
#include <search.h>
Code
ENTRY a = {"foo", "twenty"};
ENTRY b = {"bar", "three"};
if (hcreate (23)) {
    hsearch(a, ENTER);
    hsearch(b, ENTER);
}
Comments bubble
This POSIX functions maintain a single global hashmap. The GNU C library provides hcreate_r
Doc URL
https://pubs.opengroup.org/onlinepubs/9699919799/functions/hcreate.html