Remove dict_ prefix for dictionnary.

See commit on shared-pointer.
This commit is contained in:
Patrick Pelissier committed 2017-07-29 13:01:38 +02:00
1 parent f8a1832fce
commit 80c273e6e2
10 files changed
+492 -462

No files matched your search

+3 -3
View File
@@ -6,7 +6,7 @@
// Define a dictionnary of string --> int
// named 'str'
DICT_DEF2(str, string_t, STRING_OPLIST, int, M_DEFAULT_OPLIST)
DICT_DEF2(dict_str, string_t, STRING_OPLIST, int, M_DEFAULT_OPLIST)
int main(void)
{
@@ -39,10 +39,10 @@ int main(void)
printf ("Max occurence = %d\n", max);
// Iterate on the dictionnary
dict_it_str_t it;
dict_str_it_t it;
for(dict_str_it(it, h); !dict_str_end_p(it); dict_str_next(it)) {
// Get a constant reference on the pair stored in the dictionnary
const dict_pair_str_t *pair = dict_str_cref(it);
const dict_str_pair_t *pair = dict_str_cref(it);
printf ("Key=%s Value=%d\n",
string_get_cstr((*pair)->key), (*pair)->value);
}
+4 -4
View File
@@ -1,10 +1,10 @@
#include "m-dict.h"
// Let's define a dictionary of 'unsigned int' --> 'char
DICT_DEF2(m32, unsigned int, M_DEFAULT_OPLIST, char, M_DEFAULT_OPLIST)
DICT_DEF2(dict_m32, unsigned int, M_DEFAULT_OPLIST, char, M_DEFAULT_OPLIST)
// Let's create a synonym for its oplist.
#define M32_OPLIST DICT_OPLIST(m32, M_DEFAULT_OPLIST, M_DEFAULT_OPLIST)
#define M32_OPLIST DICT_OPLIST(dict_m32, M_DEFAULT_OPLIST, M_DEFAULT_OPLIST)
#if 1 // Non macro version.
@@ -16,9 +16,9 @@ int main(void) {
int is_missing = (k != NULL); // true
assert (is_missing);
dict_m32_remove(h, 5); // h is now empty
dict_it_m32_t it; // iterate over all dictionnary
dict_m32_it_t it; // iterate over all dictionnary
for (dict_m32_it (it, h) ; !dict_m32_end_p (it); dict_m32_next(it)) {
dict_pair_m32_t *item = dict_m32_ref(it);
dict_m32_pair_t *item = dict_m32_ref(it);
(*item)->value = 1; // Set its value to 1
}
dict_m32_clear(h); // h is cleared
+3 -3
View File
@@ -5,12 +5,12 @@
#include "m-dict.h"
#include "m-string.h"
DICT_DEF2(map, char, M_DEFAULT_OPLIST, int, M_DEFAULT_OPLIST)
DICT_DEF2(dict_map, char, M_DEFAULT_OPLIST, int, M_DEFAULT_OPLIST)
int main(void)
{
dict_map_t mp;
dict_it_map_t it;
dict_map_it_t it;
int choice, item;
string_t str;
char s;
@@ -76,7 +76,7 @@ int main(void)
printf("Displaying Map by Iterator:\n");
for (dict_map_it(it, mp); !dict_map_end_p(it); dict_map_next(it))
{
const dict_pair_map_t *cref = dict_map_cref(it);
const dict_map_pair_t *cref = dict_map_cref(it);
printf ("%d : %d\n", (*cref)->key, (*cref)->value);
}
break;
+2 -2
View File
@@ -5,12 +5,12 @@
/* program that reads text from standard-input,
and prints the total number of distinct words found in the text.
*/
DICT_SET_DEF2(str, string_t, STRING_OPLIST)
DICT_SET_DEF2(dict_str, string_t, STRING_OPLIST)
int main(void)
{
M_LET(word, STRING_OPLIST)
M_LET(wordcount, DICT_SET_OPLIST(str, STRING_OPLIST)) {
M_LET(wordcount, DICT_SET_OPLIST(dict_str, STRING_OPLIST)) {
while (string_fget_word(word, " \t\n,.!;:?", stdin))
dict_str_set_at(wordcount, word);
printf ("Words: %lu\n", dict_str_size(wordcount));
+2 -2
View File
@@ -16,11 +16,11 @@ VARIANT_DEF2(integer,
#define INTEGER_OPLIST VARIANT_OPLIST(integer, M_DEFAULT_OPLIST, M_CLASSIC_OPLIST(mpz))
/* Define a dictionary of string --> integer named dict_my_t */
DICT_DEF2(my,
DICT_DEF2(dict_my,
string_t, STRING_OPLIST,
integer_t, INTEGER_OPLIST)
/* Define the oplist associated to this dictionary */
#define MY_DICT_OPLIST DICT_OPLIST(my, STRING_OPLIST, INTEGER_OPLIST)
#define MY_DICT_OPLIST DICT_OPLIST(dict_my, STRING_OPLIST, INTEGER_OPLIST)
/* Define an array of such dictionary named array_my_t */
ARRAY_DEF(array_my, dict_my_t, MY_DICT_OPLIST)
+2 -2
View File
@@ -76,7 +76,7 @@ extern bool json_in_str(json_t *, FILE *);
INIT_SET(json_init_set M_IPTR), SET(json_set M_IPTR), \
OUT_STR(json_out_str), IN_STR(json_in_str M_IPTR) )
DICT_DEF2(json, string_t, STRING_OPLIST, json_t, JSON_OPLIST)
DICT_DEF2(dict_json, string_t, STRING_OPLIST, json_t, JSON_OPLIST)
ARRAY_DEF(array_json, json_t, JSON_OPLIST)
@@ -84,7 +84,7 @@ VARIANT_DEF2(variant_json,
(boolean, bool, M_OPEXTEND(M_DEFAULT_OPLIST, OUT_STR(boolean_out_str), IN_STR(boolean_in_str M_IPTR)) ),
(real, float, M_OPEXTEND (M_DEFAULT_OPLIST, OUT_STR(real_out_str), IN_STR(real_in_str M_IPTR))),
(array, array_json_t, ARRAY_OPLIST(array_json, JSON_OPLIST)),
(dict, dict_json_t, DICT_OPLIST(json, STRING_OPLIST, JSON_OPLIST)))
(dict, dict_json_t, DICT_OPLIST(dict_json, STRING_OPLIST, JSON_OPLIST)))
struct json_node_s {
variant_json_t json;