Sat, 09 Oct 2021 11:12:48 +0200
remove cxListLast (can be realized via cxListAt and index=size-1)
src/cx/list.h | file | annotate | diff | comparison | revisions | |
src/linked_list.c | file | annotate | diff | comparison | revisions | |
test/test_list.c | file | annotate | diff | comparison | revisions |
1.1 --- a/src/cx/list.h Fri Oct 08 19:47:31 2021 +0200 1.2 +++ b/src/cx/list.h Sat Oct 09 11:12:48 2021 +0200 1.3 @@ -84,11 +84,6 @@ 1.4 size_t (*find)(cx_list_s *list, void *elem); 1.5 1.6 /** 1.7 - * Member function for retrieving the last element. 1.8 - */ 1.9 - void *(*last)(cx_list_s *list); 1.10 - 1.11 - /** 1.12 * Member function for sorting the list in place. 1.13 */ 1.14 void (*sort)(cx_list_s *list); 1.15 @@ -200,20 +195,6 @@ 1.16 } 1.17 1.18 /** 1.19 - * Returns a pointer to the last element of the list. 1.20 - * 1.21 - * This is effectively the same as cxListAt() with \c index=size-1, but 1.22 - * this implementation may be more efficient depending on the list structure 1.23 - * and the conrecte implementation of cxListAt(). 1.24 - * 1.25 - * @param list the list 1.26 - * @return a pointer to the last element or \c NULL if the list is empty 1.27 - */ 1.28 -static inline void *cxListLast(CxList list) { 1.29 - return list->cl->last(list); 1.30 -} 1.31 - 1.32 -/** 1.33 * Sorts the list in place. 1.34 * 1.35 * \remark The underlying sort algorithm is implementation defined.
2.1 --- a/src/linked_list.c Fri Oct 08 19:47:31 2021 +0200 2.2 +++ b/src/linked_list.c Sat Oct 09 11:12:48 2021 +0200 2.3 @@ -456,18 +456,6 @@ 2.4 return index; 2.5 } 2.6 2.7 -static void *cx_ll_last(cx_list_s *list) { 2.8 - cx_linked_list *ll = (cx_linked_list *) list; 2.9 - cx_linked_list_node *last = ll->end; 2.10 - return last == NULL ? NULL : last->payload; 2.11 -} 2.12 - 2.13 -static void *cx_pll_last(cx_list_s *list) { 2.14 - cx_linked_list *ll = (cx_linked_list *) list; 2.15 - cx_linked_list_node *last = ll->end; 2.16 - return last == NULL ? NULL : *(void **) last->payload; 2.17 -} 2.18 - 2.19 static void cx_ll_sort(cx_list_s *list) { 2.20 cx_linked_list *ll = (cx_linked_list *) list; 2.21 cx_linked_list_sort((void **) &ll->begin, (void **) &ll->end, 2.22 @@ -488,7 +476,6 @@ 2.23 cx_ll_remove, 2.24 cx_ll_at, 2.25 cx_ll_find, 2.26 - cx_ll_last, 2.27 cx_ll_sort 2.28 }; 2.29 2.30 @@ -498,7 +485,6 @@ 2.31 cx_ll_remove, 2.32 cx_pll_at, 2.33 cx_pll_find, 2.34 - cx_pll_last, 2.35 cx_pll_sort 2.36 }; 2.37
3.1 --- a/test/test_list.c Fri Oct 08 19:47:31 2021 +0200 3.2 +++ b/test/test_list.c Sat Oct 09 11:12:48 2021 +0200 3.3 @@ -397,26 +397,6 @@ 3.4 CU_ASSERT_TRUE(cxTestingAllocatorVerify()) 3.5 } 3.6 3.7 -void test_hl_linked_list_last(void) { 3.8 - cxTestingAllocatorReset(); 3.9 - 3.10 - int data; 3.11 - CxList list = cxLinkedListCreate(cxTestingAllocator, (CxListComparator) cmp_int, sizeof(int)); 3.12 - 3.13 - CU_ASSERT_PTR_NULL(cxListLast(list)) 3.14 - 3.15 - data = 5; 3.16 - CU_ASSERT_EQUAL(cxListAdd(list, &data), 0) 3.17 - CU_ASSERT_EQUAL(*(int *) cxListLast(list), 5) 3.18 - 3.19 - data = 47; 3.20 - CU_ASSERT_EQUAL(cxListAdd(list, &data), 0) 3.21 - CU_ASSERT_EQUAL(*(int *) cxListLast(list), 47) 3.22 - 3.23 - cxLinkedListDestroy(list); 3.24 - CU_ASSERT_TRUE(cxTestingAllocatorVerify()) 3.25 -} 3.26 - 3.27 void test_hl_linked_list_insert(void) { 3.28 cxTestingAllocatorReset(); 3.29 3.30 @@ -609,23 +589,6 @@ 3.31 CU_ASSERT_TRUE(cxTestingAllocatorVerify()) 3.32 } 3.33 3.34 -void test_hl_ptr_linked_list_last(void) { 3.35 - cxTestingAllocatorReset(); 3.36 - 3.37 - CxList list = cxPointerLinkedListCreate(cxTestingAllocator, (CxListComparator) cmp_int); 3.38 - CU_ASSERT_PTR_NULL(cxListLast(list)) 3.39 - 3.40 - int a = 5, b = 47; 3.41 - 3.42 - CU_ASSERT_EQUAL(cxListAdd(list, &a), 0) 3.43 - CU_ASSERT_EQUAL(*(int *) cxListLast(list), 5) 3.44 - CU_ASSERT_EQUAL(cxListAdd(list, &b), 0) 3.45 - CU_ASSERT_EQUAL(*(int *) cxListLast(list), 47) 3.46 - 3.47 - cxLinkedListDestroy(list); 3.48 - CU_ASSERT_TRUE(cxTestingAllocatorVerify()) 3.49 -} 3.50 - 3.51 void test_hl_ptr_linked_list_insert(void) { 3.52 cxTestingAllocatorReset(); 3.53 3.54 @@ -787,7 +750,6 @@ 3.55 3.56 cu_add_test(suite, test_hl_linked_list_create); 3.57 cu_add_test(suite, test_hl_linked_list_add); 3.58 - cu_add_test(suite, test_hl_linked_list_last); 3.59 cu_add_test(suite, test_hl_linked_list_insert); 3.60 cu_add_test(suite, test_hl_linked_list_remove); 3.61 cu_add_test(suite, test_hl_linked_list_find); 3.62 @@ -797,7 +759,6 @@ 3.63 3.64 cu_add_test(suite, test_hl_ptr_linked_list_create); 3.65 cu_add_test(suite, test_hl_ptr_linked_list_add); 3.66 - cu_add_test(suite, test_hl_ptr_linked_list_last); 3.67 cu_add_test(suite, test_hl_ptr_linked_list_insert); 3.68 cu_add_test(suite, test_hl_ptr_linked_list_remove); 3.69 cu_add_test(suite, test_hl_ptr_linked_list_find);