diff --git a/doc/API.txt b/doc/API.txt index b72cfbd2..3a5c2d78 100644 --- a/doc/API.txt +++ b/doc/API.txt @@ -59,4 +59,5 @@ V0.4.*: * The order of a list initialized using M_LET is reversed V0.5.*: * M_INVERT is renamed into M_REVERSE to be more coherent with the REVERSE operator. M_INVERT is marked as obsolete. - + * Remove _it_to_p method of B+TREE / RB-TREE as it has been deprecated. + * Remove ALGO_INIT_VA & M_ALG0_LET_INIT_VAI of m-algo as it has been deprecated. Use of M_LET instead. diff --git a/m-algo.h b/m-algo.h index afbf9521..ea39680a 100644 --- a/m-algo.h +++ b/m-algo.h @@ -79,26 +79,6 @@ M_ALG0_REDUCE_DISPATCH(dest, M_GET_OPLIST M_GLOBAL_OPLIST(contOp), M_GET_SUBTYPE M_GLOBAL_OPLIST(contOp), cont, contOp, __VA_ARGS__)) \ -/* Initialize & set a container with a variable array list. - USAGE: - ALGO_INIT_VA(container, containerOplist, param1[, param2[, ...]]). - OBSOLETE: WILL BE DELETED. - */ -#define ALGO_INIT_VA(dest, contOp, ...) \ - ALGO_INIT_VAI(dest, M_GLOBAL_OPLIST(contOp), __VA_ARGS__) - - -/* Define, initialize, set & clear a container with a variable array list. - USAGE: - ALGO_LET_INIT_VA(container, containerOplist|type, param1[, param2[, ...]]) { - // Stuff with container - } - OBSOLETE: WILL BE DELETED. -*/ -#define ALGO_LET_INIT_VA(dest, contOp, ...) \ - ALGO_LET_INIT_VAI(dest, M_GLOBAL_OPLIST(contOp), __VA_ARGS__) - - /* Insert into the container 'contDst' at position 'position' all the values of container 'contSrc'. USAGE: @@ -1211,7 +1191,7 @@ #define M_ALG0_INIT_VA_FUNC(d, a) \ M_RET_ARG2 d (M_RET_ARG1 d, a) M_DEFERRED_COMMA -#define ALGO_INIT_VAI(dest, contOp, ...) \ +#define M_ALG0_INIT_VA(dest, contOp, ...) \ (void)(M_CALL_INIT(contOp, dest) M_DEFERRED_COMMA \ M_MAP2(M_ALG0_INIT_VA_FUNC, (dest, M_GET_PUSH contOp, ) , __VA_ARGS__) \ true) @@ -1223,7 +1203,7 @@ #define M_ALG0_LET_INIT_VAI(cont, dest, contOp, ...) \ for(bool cont = true; cont ; /* unused */) \ for(M_GET_TYPE contOp dest; \ - cont && (ALGO_INIT_VAI (dest, contOp, __VA_ARGS__), true); \ + cont && (M_ALG0_INIT_VA (dest, contOp, __VA_ARGS__), true); \ (M_CALL_CLEAR(contOp, dest), cont = false)) diff --git a/m-bptree.h b/m-bptree.h index 8b10400b..79fc631b 100644 --- a/m-bptree.h +++ b/m-bptree.h @@ -1085,12 +1085,6 @@ return (cmp <= 0); \ } \ \ - static inline bool M_ATTR_DEPRECATED \ - M_C(name, _it_to_p)(it_t it, key_t const key) \ - { \ - return M_C(name, _it_until_p)(it, key); \ - } \ - \ static inline value_t * \ M_C(name, _min)(const tree_t b) \ { \ diff --git a/m-rbtree.h b/m-rbtree.h index da1f3bc4..849b7152 100644 --- a/m-rbtree.h +++ b/m-rbtree.h @@ -600,12 +600,6 @@ typedef enum { return (cmp <= 0); \ } \ \ - static inline bool M_ATTR_DEPRECATED \ - M_C(name, _it_to_p)(it_t it, type const data) \ - { \ - return M_C(name, _it_until_p)(it, data); \ - } \ - \ static inline type * \ M_C(name, _min)(const tree_t tree) \ { \ diff --git a/tests/test-malgo.c b/tests/test-malgo.c index 2fe61d3d..bbe98d75 100644 --- a/tests/test-malgo.c +++ b/tests/test-malgo.c @@ -196,7 +196,8 @@ static void test_list(void) list_int_clear(l); - ALGO_INIT_VA(l, LIST_OPLIST(list_int), 1, 2, 3, 4, 5); + list_int_init(l); + for(int i = 1; i <= 5; i++) list_int_push_back(l, i); assert (list_int_size(l) == 5); algo_list_remove_val(l, 3); @@ -409,7 +410,8 @@ static void test_array(void) array_int_clear(l); - ALGO_INIT_VA(l, ARRAY_OPLIST(array_int), 1, 2, 3, 4, 5); + array_int_init(l); + for(int i = 1; i <= 5; i++) array_int_push_back(l, i); assert (array_int_size(l) == 5); assert (algo_array_sort_p(l) == true); assert (algo_array_sort_dsc_p(l) == false); @@ -419,7 +421,7 @@ static void test_array(void) array_int_clear(l); - ALGO_LET_INIT_VA(arr, array_int_t, 1, 5, 34) { + M_LET( (arr, 1, 5, 34), array_int_t) { assert (array_int_size(arr) == 3); assert (algo_array_sort_p(arr) == true); assert (algo_array_sort_dsc_p(arr) == false); @@ -579,17 +581,39 @@ LIST_DEF(lint, int) static void test_insert(void) { - ALGO_LET_INIT_VA(a, lint_t, 1, 2, 3, 4) - ALGO_LET_INIT_VA(b, aint_t, -1, -2, -3) { + M_LET( (a, 1, 2, 3, 4), aint_t) + M_LET( (b, -1, -2, -3), aint_t) { + aint_it_t i; + aint_it(i, a); + // Insert it after first element of the array. + ALGO_INSERT_AT(a, aint_t, i, b, aint_t); + M_LET( (c, 1, -1, -2, -3, 2, 3, 4), aint_t) { + assert (aint_equal_p (c, a)); + } + } + + M_LET( (a, 1, 2, 3, 4), lint_t) + M_LET( (b, -1, -2, -3), aint_t) { lint_it_t i; lint_it(i, a); - // Insert it after first element + // Insert it after first element (aka back) ALGO_INSERT_AT(a, lint_t, i, b, aint_t); - // TBC: order ok for the list (the reverse is confusing...)? - ALGO_LET_INIT_VA(c, lint_t, 1, 2, 3, -3, -2, -1, 4) { + M_LET( (c, 1, -1, -2, -3, 2, 3, 4), lint_t) { assert (lint_equal_p (c, a)); } } + + M_LET( (a, 1, 2, 3, 4), lint_t) + M_LET( (b, -1, -2, -3), lint_t) { + lint_it_t i; + lint_it(i, a); + // Insert it after first element (aka back) + ALGO_INSERT_AT(a, lint_t, i, b, lint_t); + M_LET( (c, 1, -1, -2, -3, 2, 3, 4), lint_t) { + assert (lint_equal_p (c, a)); + } + } + } static void test_string_utf8(void)