removes ucx_list_prepend_once() - this was a big mistake....

Fri, 18 Nov 2016 15:33:58 +0100

author
Mike Becker <universe@uap-core.de>
date
Fri, 18 Nov 2016 15:33:58 +0100
changeset 229
9db71925eaa8
parent 228
9f385abc72fb
child 230
4044131874f9

removes ucx_list_prepend_once() - this was a big mistake....

test/list_tests.c file | annotate | diff | comparison | revisions
test/list_tests.h file | annotate | diff | comparison | revisions
test/main.c file | annotate | diff | comparison | revisions
ucx/list.c file | annotate | diff | comparison | revisions
ucx/list.h file | annotate | diff | comparison | revisions
     1.1 --- a/test/list_tests.c	Fri Nov 18 15:17:04 2016 +0100
     1.2 +++ b/test/list_tests.c	Fri Nov 18 15:33:58 2016 +0100
     1.3 @@ -89,28 +89,6 @@
     1.4      ucx_list_free(list);
     1.5  }
     1.6  
     1.7 -UCX_TEST(test_ucx_list_prepend_once) {
     1.8 -    UcxList *list, *last, *first;
     1.9 -    list = last = ucx_list_prepend_once(NULL, (void*)" World!",
    1.10 -            ucx_strcmp, NULL);
    1.11 -    UCX_TEST_BEGIN
    1.12 -
    1.13 -    list = ucx_list_prepend_once(list, (void*)"Hello", ucx_strcmp, NULL);
    1.14 -    first = ucx_list_prepend_once(list, (void*)"Hello", ucx_strcmp, NULL);
    1.15 -    
    1.16 -    UCX_TEST_ASSERT(list == first, "'Hello' was not prepended _once_");
    1.17 -    UCX_TEST_ASSERT(first == last->prev, "does not return first element");
    1.18 -    UCX_TEST_ASSERT(strncmp((const char*)list->data, "Hello", 5) == 0,
    1.19 -            "failed");
    1.20 -    UCX_TEST_ASSERT(strncmp((const char*)list->next->data, " World!", 7) == 0,
    1.21 -            "failed");
    1.22 -    UCX_TEST_ASSERT(list->next->next == NULL, "right not terminated");
    1.23 -    UCX_TEST_ASSERT(list->prev == NULL, "left not terminated");
    1.24 -    
    1.25 -    UCX_TEST_END
    1.26 -    ucx_list_free(list);
    1.27 -}
    1.28 -
    1.29  UCX_TEST(test_ucx_list_equals) {
    1.30      const char *hello = "Hello";
    1.31      const char *world = " World!";
     2.1 --- a/test/list_tests.h	Fri Nov 18 15:17:04 2016 +0100
     2.2 +++ b/test/list_tests.h	Fri Nov 18 15:33:58 2016 +0100
     2.3 @@ -46,7 +46,6 @@
     2.4  UCX_TEST(test_ucx_list_append);
     2.5  UCX_TEST(test_ucx_list_prepend);
     2.6  UCX_TEST(test_ucx_list_append_once);
     2.7 -UCX_TEST(test_ucx_list_prepend_once);
     2.8  UCX_TEST(test_ucx_list_equals);
     2.9  UCX_TEST(test_ucx_list_concat);
    2.10  UCX_TEST(test_ucx_list_size);
     3.1 --- a/test/main.c	Fri Nov 18 15:17:04 2016 +0100
     3.2 +++ b/test/main.c	Fri Nov 18 15:33:58 2016 +0100
     3.3 @@ -138,7 +138,6 @@
     3.4          ucx_test_register(suite, test_ucx_list_append);
     3.5          ucx_test_register(suite, test_ucx_list_prepend);
     3.6          ucx_test_register(suite, test_ucx_list_append_once);
     3.7 -        ucx_test_register(suite, test_ucx_list_prepend_once);
     3.8          ucx_test_register(suite, test_ucx_list_equals);
     3.9          ucx_test_register(suite, test_ucx_list_concat);
    3.10          ucx_test_register(suite, test_ucx_list_size);
     4.1 --- a/ucx/list.c	Fri Nov 18 15:17:04 2016 +0100
     4.2 +++ b/ucx/list.c	Fri Nov 18 15:33:58 2016 +0100
     4.3 @@ -159,40 +159,6 @@
     4.4      return nl;
     4.5  }
     4.6  
     4.7 -UcxList *ucx_list_prepend_once(UcxList *l, void *data,
     4.8 -        cmp_func cmpfnc, void* cmpdata) {
     4.9 -    return ucx_list_prepend_once_a(ucx_default_allocator(), l,
    4.10 -            data, cmpfnc, cmpdata);
    4.11 -}
    4.12 -
    4.13 -UcxList *ucx_list_prepend_once_a(UcxAllocator *alloc, UcxList *l, void *data,
    4.14 -        cmp_func cmpfnc, void *cmpdata) {
    4.15 -    
    4.16 -    if (l) {
    4.17 -        int found = 0;
    4.18 -        UcxList *first;
    4.19 -        {
    4.20 -            UcxList *e = l;
    4.21 -            while (e) {
    4.22 -                found |= (cmpfnc(e->data, data, cmpdata) == 0);
    4.23 -                first = e;
    4.24 -                e = e->prev;
    4.25 -            }
    4.26 -        }
    4.27 -
    4.28 -        if (found) {
    4.29 -            return first;
    4.30 -        } else {
    4.31 -            UcxList *nl = ucx_list_append_a(alloc, NULL, data);
    4.32 -            nl->next = first;
    4.33 -            first->prev = nl;
    4.34 -            return nl;
    4.35 -        }
    4.36 -    } else {
    4.37 -        return ucx_list_append_a(alloc, NULL, data);
    4.38 -    }
    4.39 -}
    4.40 -
    4.41  UcxList *ucx_list_concat(UcxList *l1, UcxList *l2) {
    4.42      if (l1) {
    4.43          UcxList *last = ucx_list_last(l1);
     5.1 --- a/ucx/list.h	Fri Nov 18 15:17:04 2016 +0100
     5.2 +++ b/ucx/list.h	Fri Nov 18 15:33:58 2016 +0100
     5.3 @@ -276,37 +276,6 @@
     5.4  UcxList *ucx_list_prepend_a(UcxAllocator *allocator, UcxList *list, void *data);
     5.5  
     5.6  /**
     5.7 - * Inserts an element at the beginning of the list, if it is not present
     5.8 - * in the list.
     5.9 - * 
    5.10 - * @param list the list where to insert the data or <code>NULL</code> to create
    5.11 - * a new list
    5.12 - * @param data the data to insert
    5.13 - * @param cmpfnc the compare function
    5.14 - * @param cmpdata additional data for the compare function
    5.15 - * @return a pointer to the new list head
    5.16 - * @see ucx_list_prepend()
    5.17 - */
    5.18 -UcxList *ucx_list_prepend_once(UcxList *list, void *data,
    5.19 -        cmp_func cmpfnc, void *cmpdata);
    5.20 -
    5.21 -/**
    5.22 - * Inserts an element at the beginning of the list, if it is not present in
    5.23 - * the list, using a UcxAllocator.
    5.24 - * 
    5.25 - * @param allocator the allocator to use
    5.26 - * @param list the list where to insert the data or <code>NULL</code> to create
    5.27 - * a new list
    5.28 - * @param data the data to insert
    5.29 - * @param cmpfnc the compare function
    5.30 - * @param cmpdata additional data for the compare function
    5.31 - * @return a pointer to the new list head
    5.32 - * @see ucx_list_prepend_a()
    5.33 - */
    5.34 -UcxList *ucx_list_prepend_once_a(UcxAllocator *allocator,
    5.35 -        UcxList *list, void *data, cmp_func cmpfnc, void *cmpdata);
    5.36 -
    5.37 -/**
    5.38   * Concatenates two lists.
    5.39   * 
    5.40   * Either of the two arguments may be <code>NULL</code>.

mercurial