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

+33 -33
View File
@@ -988,7 +988,7 @@ This method is only defined if the type of the element defines a EQUAL method it
#### DICT\_DEF2(name, key\_type, key\_oplist, value\_type, value\_oplist)
Define the dictionary 'dict\_##name##\_t' and its associated methods as "static inline" functions.
Define the dictionary 'name##\_t' and its associated methods as "static inline" functions.
A dictionary (or associative array, map, symbol table) is an abstract data type
composed of a collection of (key, value) pairs,
such that each possible key appears at most once in the collection.
@@ -996,7 +996,7 @@ such that each possible key appears at most once in the collection.
Current implementation uses chained Hash-Table and as such, elements in the dictionary are **unordered**.
It shall be done once per type and per compilation unit.
It also define the iterator dict\_it\_##name##\_t and its associated methods as "static inline" functions.
It also define the iterator name##\_it\_t and its associated methods as "static inline" functions.
The object oplists are expected to have the following operators (INIT, INIT\_SET, SET and CLEAR), otherwise default operators are used.
If there is no given oplist, the default operators are also used. The created methods will use the operators to init, set and clear the contained object.
@@ -1006,7 +1006,7 @@ Interface is subjected to minor change.
Example:
DICT_DEF2(str, string_t, STRING_OPLIST, string_t, STRING_OPLIST)
DICT_DEF2(dict_str, string_t, STRING_OPLIST, string_t, STRING_OPLIST)
dict_str_t my_dict;
void f(string_t key, string_t value) {
dict_str_set_at (my_dict, key, value);
@@ -1015,13 +1015,13 @@ Example:
#### DICT\_OA\_DEF2(name, key\_type, key\_oplist, value\_type, value\_oplist)
Define the dictionary 'dict\_##name##\_t' and its associated methods
Define the dictionary 'name##\_t' and its associated methods
as "static inline" functions much like DICT\_DEF2.
The difference is that it uses an Open Addressiong Hash-Table as
container.
It shall be done once per type and per compilation unit.
It also define the iterator dict\_it\_##name##\_t and its associated methods as "static inline" functions.
It also define the iterator name##\_it\_t and its associated methods as "static inline" functions.
The object oplists are expected to have the following operators
(INIT, INIT\_SET, SET, CLEAR), otherwise default operators are used.
@@ -1044,7 +1044,7 @@ Example:
*k = (int)-n-1;
}
DICT_OA_DEF2(int, int, M_OPEXTEND(M_DEFAULT_OPLIST, OOR_EQUAL(oor_equal_p), OOR_SET(oor_set M_IPTR)), int64_t, M_DEFAULT_OPLIST)
DICT_OA_DEF2(dict_int, int, M_OPEXTEND(M_DEFAULT_OPLIST, OOR_EQUAL(oor_equal_p), OOR_SET(oor_set M_IPTR)), int64_t, M_DEFAULT_OPLIST)
dict_int_t my_dict;
void f(int key, int64_t value) {
@@ -1058,11 +1058,11 @@ Return the oplist of the dictionary defined by calling DICT\_DEF2 with name & ke
#### DICT\_SET\_DEF2(name, key\_type, key\_oplist)
Define the set 'dict\_##name##\_t' and its associated methods as "static inline" functions.
Define the set 'name##\_t' and its associated methods as "static inline" functions.
A set is a specialized version of a dictionary with no value.
It shall be done once per type and per compilation unit.
It also define the iterator dict\_it\_##name##\_t and its associated methods as "static inline" functions.
It also define the iterator name##\_it\_t and its associated methods as "static inline" functions.
The oplist is expected to have the following operators (INIT, INIT\_SET, SET, CLEAR, HASH and EQUAL), otherwise default operators are used.
If there is no given oplist, the default operators are also used. The created methods will use the operators to init, set and clear the contained object.
@@ -1071,7 +1071,7 @@ Interface is subjected to minor change.
Example:
DICT_SET_DEF2(strSet, string_t, STRING_OPLIST)
DICT_SET_DEF2(dict_strSet, string_t, STRING_OPLIST)
dict_strSet_t set;
void f(string_t key) {
dict_strSet_set_at (set, key);
@@ -1086,112 +1086,112 @@ Return the oplist of the set defined by calling DICT\_SET\_DEF2 with name & key\
In the following methods, name stands for the name given to the macro which is used to identify the type.
The following types are automatically defined by the previous macro:
##### dict\_name\_t
##### name\_t
Type of the dictionary of 'key_type' --> 'value_type'.
##### dict\_it\_name\_t
##### name\_it\_t
Type of an iterator over this dictionary.
The following methods are automatically and properly created by the previous macro:
##### void dict\_name\_init(dict\_name\_t dict)
##### void name\_init(name\_t dict)
Initialize the dictionary 'dict' to be empty.
##### void dict\_name\_clear(dict\_name\_t dict)
##### void name\_clear(name\_t dict)
Clear the dictionary 'dict'.
##### void dict\_name\_init\_set(dict\_name\_t dict, const dict\_name\_t ref)
##### void name\_init\_set(name\_t dict, const name\_t ref)
Initialize the dictionary 'dict' to be the same as 'ref'.
##### void dict\_name\_set(dict\_name\_t dict, const dict\_name\_t ref)
##### void name\_set(name\_t dict, const name\_t ref)
Set the dictionary 'dict' to be the same as 'ref'.
##### void dict\_name\_init\_move(dict\_name\_t dict, dict\_name\_t ref)
##### void name\_init\_move(name\_t dict, name\_t ref)
Initialize the dictionary 'dict' by stealing as resource as possible
from 'ref' and clear 'ref'.
##### void dict\_name\_move(dict\_name\_t dict, dict\_name\_t ref)
##### void name\_move(name\_t dict, name\_t ref)
Set the dictionary 'dict' by stealing as resource as possible
from 'ref' and clear 'ref'.
##### void dict\_name\_clean(dict\_name\_t dict)
##### void name\_clean(name\_t dict)
Clean the dictionary 'dict'. 'dict' remains initialized.
##### size\_t dict\_name\_size(const dict\_name\_t dict)
##### size\_t name\_size(const name\_t dict)
Return the number of elements of the dictionary.
##### value\_type \*dict\_name\_get(const dict\_name\_t dict, const key\_type key)
##### value\_type \*name\_get(const name\_t dict, const key\_type key)
Return a pointer to the value associated to the key 'key' in dictionary
'dict' or NULL if the key is not found.
##### void dict\_name\_set\_at(dict\_name\_t dict, const key\_type key, const value\_type value)
##### void name\_set\_at(name\_t dict, const key\_type key, const value\_type value)
Set the value referenced by key 'key' in the dictionary 'dict' to 'value'.
##### void dict\_name\_remove(dict\_name\_t dict, const key\_type key)
##### void name\_remove(name\_t dict, const key\_type key)
Remove the element referenced by key 'key' in the dictionary 'dict'.
Do nothing if 'key' is no present in the dictionary.
##### void dict\_name\_it(dict\_it\_name\_t it, dict\_name\_t dict)
##### void name\_it(name\_it\_t it, name\_t dict)
Set the iterator 'it' to the first element of 'dict'.
##### void dict\_name\_it\_set(dict\_it\_name\_t it, const dict\_it\_name\_t ref)
##### void name\_it\_set(name\_it\_t it, const name\_it\_t ref)
Set the iterator 'it' to the same element than 'ref'.
##### bool dict\_name\_end\_p(const dict\_it\_name\_t it)
##### bool name\_end\_p(const name\_it\_t it)
Return true if 'it' references no longer a valid element.
##### bool dict\_name\_last\_p(const dict\_it\_name\_t it)
##### bool name\_last\_p(const name\_it\_t it)
Return true if 'it' references the last element or is no longer valid.
##### void dict\_name\_next(dict\_it\_name\_t it)
##### void name\_next(name\_it\_t it)
Update the iterator 'it' to the next element.
##### dict\_pair\_name\_t *dict\_name\_ref(dict\_it\_name\_t it)
##### name\_pair\_t *name\_ref(name\_it\_t it)
Return a pointer to the pair composed by the key and its value.
'key' element can not be modified.
This pointer remains valid until the dictionary is modified by another method.
##### const dict\_pair\_name\_t *dict\_name\_ref(dict\_it\_name\_t it)
##### const name\_pair\_t *name\_ref(name\_it\_t it)
Return a constant pointer to the pair composed by the key and its value.
This pointer remains valid until the dictionary is modified by another method.
##### void dict\_name\_get\_str(string\_t str, const dict\_name\_t dict, bool append)
##### void name\_get\_str(string\_t str, const name\_t dict, bool append)
Generate a string representation of the dict 'dict' and set 'str' to this representation
(if 'append' is false) or append 'str' with this representation (if 'append' is true).
This method is only defined if the type of the element defines a GET\_STR method itself.
##### void dict\_name\_out\_str(FILE *file, const dict\_name\_t dict)
##### void name\_out\_str(FILE *file, const name\_t dict)
Generate a string representation of the dict 'dict' and outputs it into the FILE 'file'.
This method is only defined if the type of the element defines a OUT\_STR method itself.
##### void dict\_name\_in\_str(FILE *file, const dict\_name\_t dict)
##### void name\_in\_str(FILE *file, const name\_t dict)
Read from the file 'file' a string representation of a dict and set 'dict' to this representation.
This method is only defined if the type of the element defines a IN\_STR method itself.
##### bool dict\_name\_equal\_p(const dict\_name\_t dict1, const dict\_name\_t dict2)
##### bool name\_equal\_p(const name\_t dict1, const name\_t dict2)
Return true if both dicts 'dict1' and 'dict2' are equal.
This method is only defined if the type of the element defines a EQUAL method itself.
+13 -11
View File
@@ -100,9 +100,9 @@ static void test_rbtree(size_t n)
/********************************************************************************************/
#ifdef USE_MEMPOOL
DICT_DEF2(ulong, unsigned long, M_OPEXTEND(M_DEFAULT_OPLIST, MEMPOOL(dict_mpool), MEMPOOL_LINKAGE(static)), unsigned long, M_DEFAULT_OPLIST)
DICT_DEF2(dict_ulong, unsigned long, M_OPEXTEND(M_DEFAULT_OPLIST, MEMPOOL(dict_mpool), MEMPOOL_LINKAGE(static)), unsigned long, M_DEFAULT_OPLIST)
#else
DICT_DEF2(ulong, unsigned long, M_DEFAULT_OPLIST, unsigned long, M_DEFAULT_OPLIST)
DICT_DEF2(dict_ulong, unsigned long, M_DEFAULT_OPLIST, unsigned long, M_DEFAULT_OPLIST)
#endif
static void
@@ -111,7 +111,7 @@ test_dict(unsigned long n)
#ifdef USE_MEMPOOL
mempool_list_dict_pair_ulong_init(dict_mpool);
#endif
M_LET(dict, DICT_OPLIST(ulong)) {
M_LET(dict, DICT_OPLIST(dict_ulong)) {
for (size_t i = 0; i < n; i++) {
unsigned long key = rand_get();
dict_ulong_set_at(dict, key, rand_get() );
@@ -142,12 +142,14 @@ static inline void oor_set(unsigned long *k, unsigned char n)
*k = (unsigned long)n;
}
DICT_OA_DEF2(oa_ulong, unsigned long, M_OPEXTEND(M_DEFAULT_OPLIST, OOR_EQUAL(oor_equal_p), OOR_SET(oor_set M_IPTR)), unsigned long, M_DEFAULT_OPLIST)
DICT_OA_DEF2(dict_oa_ulong,
unsigned long, M_OPEXTEND(M_DEFAULT_OPLIST, OOR_EQUAL(oor_equal_p), OOR_SET(oor_set M_IPTR)),
unsigned long, M_DEFAULT_OPLIST)
static void
test_dict_oa(unsigned long n)
{
M_LET(dict, DICT_OPLIST(oa_ulong)) {
M_LET(dict, DICT_OPLIST(dict_oa_ulong)) {
for (size_t i = 0; i < n; i++) {
dict_oa_ulong_set_at(dict, rand_get(), rand_get() );
}
@@ -175,9 +177,9 @@ static size_t char_hash(const char_array_t a) { return m_core_hash (a, strlen(a)
#define CHAR_OPLIST (INIT(char_init), INIT_SET(char_set), SET(char_set), CLEAR(char_init), HASH(char_hash), EQUAL(char_equal_p))
#ifdef USE_MEMPOOL
DICT_DEF2(char, char_array_t, M_OPEXTEND(CHAR_OPLIST,MEMPOOL(dict_mpool2), MEMPOOL_LINKAGE(static)), char_array_t, CHAR_OPLIST)
DICT_DEF2(dict_char, char_array_t, M_OPEXTEND(CHAR_OPLIST,MEMPOOL(dict_mpool2), MEMPOOL_LINKAGE(static)), char_array_t, CHAR_OPLIST)
#else
DICT_DEF2(char, char_array_t, CHAR_OPLIST, char_array_t, CHAR_OPLIST)
DICT_DEF2(dict_char, char_array_t, CHAR_OPLIST, char_array_t, CHAR_OPLIST)
#endif
static void
@@ -186,7 +188,7 @@ test_dict_big(unsigned long n)
#ifdef USE_MEMPOOL
mempool_list_dict_pair_char_init(dict_mpool2);
#endif
M_LET(dict, DICT_OPLIST(char)) {
M_LET(dict, DICT_OPLIST(dict_char)) {
for (size_t i = 0; i < n; i++) {
char_array_t s1, s2;
sprintf(s1, "%u", rand_get());
@@ -212,9 +214,9 @@ test_dict_big(unsigned long n)
/********************************************************************************************/
#ifdef USE_MEMPOOL
DICT_DEF2(str, string_t, M_OPEXTEND(STRING_OPLIST, MEMPOOL(dict_mpool3), MEMPOOL_LINKAGE(static)), string_t, STRING_OPLIST)
DICT_DEF2(dict_str, string_t, M_OPEXTEND(STRING_OPLIST, MEMPOOL(dict_mpool3), MEMPOOL_LINKAGE(static)), string_t, STRING_OPLIST)
#else
DICT_DEF2(str, string_t, STRING_OPLIST, string_t, STRING_OPLIST)
DICT_DEF2(dict_str, string_t, STRING_OPLIST, string_t, STRING_OPLIST)
#endif
static void
@@ -224,7 +226,7 @@ test_dict_str(unsigned long n)
mempool_list_dict_pair_str_init(dict_mpool3);
#endif
M_LET(s1, s2, STRING_OPLIST)
M_LET(dict, DICT_OPLIST(str)) {
M_LET(dict, DICT_OPLIST(dict_str)) {
for (size_t i = 0; i < n; i++) {
string_printf(s1, "%u", rand_get());
string_printf(s2, "%u", rand_get());
+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;
+416 -388
View File
File diff suppressed because it is too large. Load diff
+14 -14
View File
@@ -38,11 +38,11 @@ static inline void oor_set(int *k, unsigned char n)
#include "coverage.h"
START_COVERAGE
DICT_DEF2(str, string_t, STRING_OPLIST, string_t, STRING_OPLIST)
DICT_OA_DEF2(oa_int, int, M_OPEXTEND(M_DEFAULT_OPLIST, OOR_EQUAL(oor_equal_p), OOR_SET(oor_set M_IPTR)), int, M_DEFAULT_OPLIST)
DICT_DEF2(dict_str, string_t, STRING_OPLIST, string_t, STRING_OPLIST)
DICT_OA_DEF2(dict_oa_int, int, M_OPEXTEND(M_DEFAULT_OPLIST, OOR_EQUAL(oor_equal_p), OOR_SET(oor_set M_IPTR)), int, M_DEFAULT_OPLIST)
END_COVERAGE
DICT_SET_DEF2(setstr, string_t, STRING_OPLIST)
DICT_SET_DEF2(dict_setstr, string_t, STRING_OPLIST)
/* Helper structure */
ARRAY_DEF(array_string, string_t, STRING_OPLIST)
@@ -92,7 +92,7 @@ static void test_data(void)
static void check_io(void)
{
M_LET(str, STRING_OPLIST)
M_LET(dict, DICT_OPLIST(str)) {
M_LET(dict, DICT_OPLIST(dict_str)) {
dict_str_get_str(str, dict, false);
assert (string_cmp_str (str, "{}") == 0);
dict_str_set_at (dict, STRING_CTE("LICENCE"), STRING_CTE("BSD3"));
@@ -108,7 +108,7 @@ static void check_io(void)
fclose (f);
f = fopen ("a.dat", "rt");
if (!f) abort();
M_LET(dict2, DICT_OPLIST(str)) {
M_LET(dict2, DICT_OPLIST(dict_str)) {
bool b = dict_str_in_str(dict2, f);
assert (b == true);
/* assert (dict_str_equal_p (dict, dict2)); */
@@ -120,7 +120,7 @@ static void check_io(void)
static void test_set(void)
{
M_LET(str, STRING_OPLIST)
M_LET(set, DICT_SET_OPLIST(setstr, STRING_OPLIST)) {
M_LET(set, DICT_SET_OPLIST(dict_setstr, STRING_OPLIST)) {
for(int i = 0; i < 100; i++) {
string_printf(str, "%d", i);
dict_setstr_set_at(set, str);
@@ -136,7 +136,7 @@ static void test_set(void)
static void test_init(void)
{
M_LET(str1, str2, STRING_OPLIST)
M_LET(d1, d2, DICT_OPLIST(str, STRING_OPLIST_, STRING_OPLIST)){
M_LET(d1, d2, DICT_OPLIST(dict_str, STRING_OPLIST_, STRING_OPLIST)){
for(size_t i = 0; i < 100; i++) {
string_printf(str1, "%d", 2*i);
string_printf(str2, "%d", 2*i+1);
@@ -233,7 +233,7 @@ static void test1(void)
size_t s = 0;
bool check1 = false, check2= false;
for M_EACH(r, dict, DICT_OPLIST(str)) {
for M_EACH(r, dict, DICT_OPLIST(dict_str)) {
if (string_cmp_str((*r)->key, "README") == 0)
check1 = true;
if (string_cmp_str((*r)->value, "BSD3") == 0)
@@ -277,7 +277,7 @@ static void test_oa(void)
static void test_init_oa(void)
{
M_LET(d1, d2, DICT_OPLIST(oa_int, M_DEFAULT_OPLIST, M_DEFAULT_OPLIST)){
M_LET(d1, d2, DICT_OPLIST(dict_oa_int, M_DEFAULT_OPLIST, M_DEFAULT_OPLIST)){
for(size_t i = 0; i < 100; i++) {
dict_oa_int_set_at (d1, 2*i, 2*i+1);
}
@@ -337,16 +337,16 @@ static void test_init_oa(void)
static void test_it_oa(void)
{
M_LET(d1, DICT_OPLIST(oa_int, M_DEFAULT_OPLIST, M_DEFAULT_OPLIST)){
M_LET(d1, DICT_OPLIST(dict_oa_int, M_DEFAULT_OPLIST, M_DEFAULT_OPLIST)){
for(size_t i = 0; i < 100; i++) {
dict_oa_int_set_at (d1, 2*i, 2*i+1);
}
assert (dict_oa_int_size (d1) == 100);
dict_it_oa_int_t it;
dict_oa_int_it_t it;
size_t s = 0;
for(dict_oa_int_it(it, d1); !dict_oa_int_end_p(it); dict_oa_int_next(it)) {
dict_pair_oa_int_t *pair = dict_oa_int_ref(it);
dict_oa_int_pair_t *pair = dict_oa_int_ref(it);
assert (pair->key >= 0 && pair->key < 200);
assert (pair->value == pair->key + 1);
s++;
@@ -359,7 +359,7 @@ static void test_it_oa(void)
dict_oa_int_previous(it);
assert (!dict_oa_int_end_p(it));
assert (dict_oa_int_last_p(it));
dict_it_oa_int_t it2;
dict_oa_int_it_t it2;
dict_oa_int_it_last(it2, d1);
assert (dict_oa_int_it_equal_p(it2, it));
dict_oa_int_it(it2, d1);
@@ -372,7 +372,7 @@ static void test_it_oa(void)
s = 0;
for(dict_oa_int_it_last(it, d1); !dict_oa_int_end_p(it); dict_oa_int_previous(it)) {
dict_pair_oa_int_t *pair = dict_oa_int_ref(it);
dict_oa_int_pair_t *pair = dict_oa_int_ref(it);
assert (pair->key >= 0 && pair->key < 200);
assert (pair->value == pair->key + 1);
s++;