Mon, 30 Dec 2019 09:54:10 +0100
Added tag v2.1 for changeset 871a8ffe6c9d
103
08018864fb91
added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents:
93
diff
changeset
|
1 | /* |
08018864fb91
added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents:
93
diff
changeset
|
2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
08018864fb91
added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents:
93
diff
changeset
|
3 | * |
259 | 4 | * Copyright 2017 Mike Becker, Olaf Wintermann All rights reserved. |
103
08018864fb91
added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents:
93
diff
changeset
|
5 | * |
08018864fb91
added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents:
93
diff
changeset
|
6 | * Redistribution and use in source and binary forms, with or without |
08018864fb91
added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents:
93
diff
changeset
|
7 | * modification, are permitted provided that the following conditions are met: |
08018864fb91
added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents:
93
diff
changeset
|
8 | * |
08018864fb91
added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents:
93
diff
changeset
|
9 | * 1. Redistributions of source code must retain the above copyright |
08018864fb91
added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents:
93
diff
changeset
|
10 | * notice, this list of conditions and the following disclaimer. |
08018864fb91
added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents:
93
diff
changeset
|
11 | * |
08018864fb91
added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents:
93
diff
changeset
|
12 | * 2. Redistributions in binary form must reproduce the above copyright |
08018864fb91
added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents:
93
diff
changeset
|
13 | * notice, this list of conditions and the following disclaimer in the |
08018864fb91
added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents:
93
diff
changeset
|
14 | * documentation and/or other materials provided with the distribution. |
08018864fb91
added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents:
93
diff
changeset
|
15 | * |
08018864fb91
added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents:
93
diff
changeset
|
16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
08018864fb91
added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents:
93
diff
changeset
|
17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
08018864fb91
added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents:
93
diff
changeset
|
18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
08018864fb91
added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents:
93
diff
changeset
|
19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
08018864fb91
added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents:
93
diff
changeset
|
20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
08018864fb91
added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents:
93
diff
changeset
|
21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
08018864fb91
added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents:
93
diff
changeset
|
22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
08018864fb91
added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents:
93
diff
changeset
|
23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
08018864fb91
added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents:
93
diff
changeset
|
24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
08018864fb91
added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents:
93
diff
changeset
|
25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
08018864fb91
added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents:
93
diff
changeset
|
26 | * POSSIBILITY OF SUCH DAMAGE. |
08018864fb91
added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents:
93
diff
changeset
|
27 | */ |
08018864fb91
added license and copyright notice to all files
Mike Becker <universe@uap-core.de>
parents:
93
diff
changeset
|
28 | |
251
fae240d633fc
changes source directory structure in preperation for autotools rollout
Mike Becker <universe@uap-core.de>
parents:
250
diff
changeset
|
29 | #include "ucx/list.h" |
4 | 30 | |
371
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
31 | UcxList *ucx_list_clone(const UcxList *l, copy_func fnc, void *data) { |
125
fca8efb122de
changed suffix for allocator aware functions + added allocator aware functions for UcxList
Mike Becker <universe@uap-core.de>
parents:
123
diff
changeset
|
32 | return ucx_list_clone_a(ucx_default_allocator(), l, fnc, data); |
fca8efb122de
changed suffix for allocator aware functions + added allocator aware functions for UcxList
Mike Becker <universe@uap-core.de>
parents:
123
diff
changeset
|
33 | } |
fca8efb122de
changed suffix for allocator aware functions + added allocator aware functions for UcxList
Mike Becker <universe@uap-core.de>
parents:
123
diff
changeset
|
34 | |
371
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
35 | UcxList *ucx_list_clone_a(UcxAllocator *alloc, const UcxList *l, |
125
fca8efb122de
changed suffix for allocator aware functions + added allocator aware functions for UcxList
Mike Becker <universe@uap-core.de>
parents:
123
diff
changeset
|
36 | copy_func fnc, void *data) { |
122
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
121
diff
changeset
|
37 | UcxList *ret = NULL; |
125
fca8efb122de
changed suffix for allocator aware functions + added allocator aware functions for UcxList
Mike Becker <universe@uap-core.de>
parents:
123
diff
changeset
|
38 | while (l) { |
fca8efb122de
changed suffix for allocator aware functions + added allocator aware functions for UcxList
Mike Becker <universe@uap-core.de>
parents:
123
diff
changeset
|
39 | if (fnc) { |
fca8efb122de
changed suffix for allocator aware functions + added allocator aware functions for UcxList
Mike Becker <universe@uap-core.de>
parents:
123
diff
changeset
|
40 | ret = ucx_list_append_a(alloc, ret, fnc(l->data, data)); |
18
69636f81db31
added clone and equals to lists
Mike Becker <universe@uap-core.de>
parents:
13
diff
changeset
|
41 | } else { |
125
fca8efb122de
changed suffix for allocator aware functions + added allocator aware functions for UcxList
Mike Becker <universe@uap-core.de>
parents:
123
diff
changeset
|
42 | ret = ucx_list_append_a(alloc, ret, l->data); |
18
69636f81db31
added clone and equals to lists
Mike Becker <universe@uap-core.de>
parents:
13
diff
changeset
|
43 | } |
69636f81db31
added clone and equals to lists
Mike Becker <universe@uap-core.de>
parents:
13
diff
changeset
|
44 | l = l->next; |
69636f81db31
added clone and equals to lists
Mike Becker <universe@uap-core.de>
parents:
13
diff
changeset
|
45 | } |
69636f81db31
added clone and equals to lists
Mike Becker <universe@uap-core.de>
parents:
13
diff
changeset
|
46 | return ret; |
69636f81db31
added clone and equals to lists
Mike Becker <universe@uap-core.de>
parents:
13
diff
changeset
|
47 | } |
69636f81db31
added clone and equals to lists
Mike Becker <universe@uap-core.de>
parents:
13
diff
changeset
|
48 | |
122
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
121
diff
changeset
|
49 | int ucx_list_equals(const UcxList *l1, const UcxList *l2, |
67
27e67e725d35
added some qualifiers + removed pointer alias in mergesort
Mike Becker <universe@uap-core.de>
parents:
37
diff
changeset
|
50 | cmp_func fnc, void* data) { |
18
69636f81db31
added clone and equals to lists
Mike Becker <universe@uap-core.de>
parents:
13
diff
changeset
|
51 | if (l1 == l2) return 1; |
69636f81db31
added clone and equals to lists
Mike Becker <universe@uap-core.de>
parents:
13
diff
changeset
|
52 | |
69636f81db31
added clone and equals to lists
Mike Becker <universe@uap-core.de>
parents:
13
diff
changeset
|
53 | while (l1 != NULL && l2 != NULL) { |
69636f81db31
added clone and equals to lists
Mike Becker <universe@uap-core.de>
parents:
13
diff
changeset
|
54 | if (fnc == NULL) { |
69636f81db31
added clone and equals to lists
Mike Becker <universe@uap-core.de>
parents:
13
diff
changeset
|
55 | if (l1->data != l2->data) return 0; |
69636f81db31
added clone and equals to lists
Mike Becker <universe@uap-core.de>
parents:
13
diff
changeset
|
56 | } else { |
69636f81db31
added clone and equals to lists
Mike Becker <universe@uap-core.de>
parents:
13
diff
changeset
|
57 | if (fnc(l1->data, l2->data, data) != 0) return 0; |
69636f81db31
added clone and equals to lists
Mike Becker <universe@uap-core.de>
parents:
13
diff
changeset
|
58 | } |
69636f81db31
added clone and equals to lists
Mike Becker <universe@uap-core.de>
parents:
13
diff
changeset
|
59 | l1 = l1->next; |
69636f81db31
added clone and equals to lists
Mike Becker <universe@uap-core.de>
parents:
13
diff
changeset
|
60 | l2 = l2->next; |
69636f81db31
added clone and equals to lists
Mike Becker <universe@uap-core.de>
parents:
13
diff
changeset
|
61 | } |
69636f81db31
added clone and equals to lists
Mike Becker <universe@uap-core.de>
parents:
13
diff
changeset
|
62 | |
69636f81db31
added clone and equals to lists
Mike Becker <universe@uap-core.de>
parents:
13
diff
changeset
|
63 | return (l1 == NULL && l2 == NULL); |
69636f81db31
added clone and equals to lists
Mike Becker <universe@uap-core.de>
parents:
13
diff
changeset
|
64 | } |
69636f81db31
added clone and equals to lists
Mike Becker <universe@uap-core.de>
parents:
13
diff
changeset
|
65 | |
122
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
121
diff
changeset
|
66 | void ucx_list_free(UcxList *l) { |
125
fca8efb122de
changed suffix for allocator aware functions + added allocator aware functions for UcxList
Mike Becker <universe@uap-core.de>
parents:
123
diff
changeset
|
67 | ucx_list_free_a(ucx_default_allocator(), l); |
fca8efb122de
changed suffix for allocator aware functions + added allocator aware functions for UcxList
Mike Becker <universe@uap-core.de>
parents:
123
diff
changeset
|
68 | } |
fca8efb122de
changed suffix for allocator aware functions + added allocator aware functions for UcxList
Mike Becker <universe@uap-core.de>
parents:
123
diff
changeset
|
69 | |
fca8efb122de
changed suffix for allocator aware functions + added allocator aware functions for UcxList
Mike Becker <universe@uap-core.de>
parents:
123
diff
changeset
|
70 | void ucx_list_free_a(UcxAllocator *alloc, UcxList *l) { |
122
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
121
diff
changeset
|
71 | UcxList *e = l, *f; |
8 | 72 | while (e != NULL) { |
73 | f = e; | |
74 | e = e->next; | |
173
31a8682fffb7
fixed some sstring issues + added allocator macros
Mike Becker <universe@uap-core.de>
parents:
172
diff
changeset
|
75 | alfree(alloc, f); |
8 | 76 | } |
77 | } | |
78 | ||
212
c766c423dee6
fixed name of ucx_list_free_content()
Mike Becker <universe@uap-core.de>
parents:
211
diff
changeset
|
79 | void ucx_list_free_content(UcxList* list, ucx_destructor destr) { |
277
f819fe5e20f5
makes destructor functions for *_free_content() optional + more documentation for UcxProperties
Mike Becker <universe@uap-core.de>
parents:
259
diff
changeset
|
80 | if (!destr) destr = free; |
211
07a284486fa1
added ucx_list_free_contents()
Mike Becker <universe@uap-core.de>
parents:
192
diff
changeset
|
81 | while (list != NULL) { |
07a284486fa1
added ucx_list_free_contents()
Mike Becker <universe@uap-core.de>
parents:
192
diff
changeset
|
82 | destr(list->data); |
07a284486fa1
added ucx_list_free_contents()
Mike Becker <universe@uap-core.de>
parents:
192
diff
changeset
|
83 | list = list->next; |
07a284486fa1
added ucx_list_free_contents()
Mike Becker <universe@uap-core.de>
parents:
192
diff
changeset
|
84 | } |
07a284486fa1
added ucx_list_free_contents()
Mike Becker <universe@uap-core.de>
parents:
192
diff
changeset
|
85 | } |
07a284486fa1
added ucx_list_free_contents()
Mike Becker <universe@uap-core.de>
parents:
192
diff
changeset
|
86 | |
122
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
121
diff
changeset
|
87 | UcxList *ucx_list_append(UcxList *l, void *data) { |
125
fca8efb122de
changed suffix for allocator aware functions + added allocator aware functions for UcxList
Mike Becker <universe@uap-core.de>
parents:
123
diff
changeset
|
88 | return ucx_list_append_a(ucx_default_allocator(), l, data); |
fca8efb122de
changed suffix for allocator aware functions + added allocator aware functions for UcxList
Mike Becker <universe@uap-core.de>
parents:
123
diff
changeset
|
89 | } |
fca8efb122de
changed suffix for allocator aware functions + added allocator aware functions for UcxList
Mike Becker <universe@uap-core.de>
parents:
123
diff
changeset
|
90 | |
fca8efb122de
changed suffix for allocator aware functions + added allocator aware functions for UcxList
Mike Becker <universe@uap-core.de>
parents:
123
diff
changeset
|
91 | UcxList *ucx_list_append_a(UcxAllocator *alloc, UcxList *l, void *data) { |
173
31a8682fffb7
fixed some sstring issues + added allocator macros
Mike Becker <universe@uap-core.de>
parents:
172
diff
changeset
|
92 | UcxList *nl = (UcxList*) almalloc(alloc, sizeof(UcxList)); |
125
fca8efb122de
changed suffix for allocator aware functions + added allocator aware functions for UcxList
Mike Becker <universe@uap-core.de>
parents:
123
diff
changeset
|
93 | if (!nl) { |
fca8efb122de
changed suffix for allocator aware functions + added allocator aware functions for UcxList
Mike Becker <universe@uap-core.de>
parents:
123
diff
changeset
|
94 | return NULL; |
fca8efb122de
changed suffix for allocator aware functions + added allocator aware functions for UcxList
Mike Becker <universe@uap-core.de>
parents:
123
diff
changeset
|
95 | } |
7
68091406d1cf
added dlist to makefile, implemented first functions, discarded some fails
Mike Becker <universe@uap-core.de>
parents:
4
diff
changeset
|
96 | |
8 | 97 | nl->data = data; |
98 | nl->next = NULL; | |
125
fca8efb122de
changed suffix for allocator aware functions + added allocator aware functions for UcxList
Mike Becker <universe@uap-core.de>
parents:
123
diff
changeset
|
99 | if (l) { |
122
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
121
diff
changeset
|
100 | UcxList *t = ucx_list_last(l); |
8 | 101 | t->next = nl; |
102 | nl->prev = t; | |
103 | return l; | |
125
fca8efb122de
changed suffix for allocator aware functions + added allocator aware functions for UcxList
Mike Becker <universe@uap-core.de>
parents:
123
diff
changeset
|
104 | } else { |
fca8efb122de
changed suffix for allocator aware functions + added allocator aware functions for UcxList
Mike Becker <universe@uap-core.de>
parents:
123
diff
changeset
|
105 | nl->prev = NULL; |
fca8efb122de
changed suffix for allocator aware functions + added allocator aware functions for UcxList
Mike Becker <universe@uap-core.de>
parents:
123
diff
changeset
|
106 | return nl; |
8 | 107 | } |
7
68091406d1cf
added dlist to makefile, implemented first functions, discarded some fails
Mike Becker <universe@uap-core.de>
parents:
4
diff
changeset
|
108 | } |
68091406d1cf
added dlist to makefile, implemented first functions, discarded some fails
Mike Becker <universe@uap-core.de>
parents:
4
diff
changeset
|
109 | |
122
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
121
diff
changeset
|
110 | UcxList *ucx_list_prepend(UcxList *l, void *data) { |
125
fca8efb122de
changed suffix for allocator aware functions + added allocator aware functions for UcxList
Mike Becker <universe@uap-core.de>
parents:
123
diff
changeset
|
111 | return ucx_list_prepend_a(ucx_default_allocator(), l, data); |
fca8efb122de
changed suffix for allocator aware functions + added allocator aware functions for UcxList
Mike Becker <universe@uap-core.de>
parents:
123
diff
changeset
|
112 | } |
fca8efb122de
changed suffix for allocator aware functions + added allocator aware functions for UcxList
Mike Becker <universe@uap-core.de>
parents:
123
diff
changeset
|
113 | |
fca8efb122de
changed suffix for allocator aware functions + added allocator aware functions for UcxList
Mike Becker <universe@uap-core.de>
parents:
123
diff
changeset
|
114 | UcxList *ucx_list_prepend_a(UcxAllocator *alloc, UcxList *l, void *data) { |
fca8efb122de
changed suffix for allocator aware functions + added allocator aware functions for UcxList
Mike Becker <universe@uap-core.de>
parents:
123
diff
changeset
|
115 | UcxList *nl = ucx_list_append_a(alloc, NULL, data); |
fca8efb122de
changed suffix for allocator aware functions + added allocator aware functions for UcxList
Mike Becker <universe@uap-core.de>
parents:
123
diff
changeset
|
116 | if (!nl) { |
fca8efb122de
changed suffix for allocator aware functions + added allocator aware functions for UcxList
Mike Becker <universe@uap-core.de>
parents:
123
diff
changeset
|
117 | return NULL; |
fca8efb122de
changed suffix for allocator aware functions + added allocator aware functions for UcxList
Mike Becker <universe@uap-core.de>
parents:
123
diff
changeset
|
118 | } |
fca8efb122de
changed suffix for allocator aware functions + added allocator aware functions for UcxList
Mike Becker <universe@uap-core.de>
parents:
123
diff
changeset
|
119 | l = ucx_list_first(l); |
7
68091406d1cf
added dlist to makefile, implemented first functions, discarded some fails
Mike Becker <universe@uap-core.de>
parents:
4
diff
changeset
|
120 | |
125
fca8efb122de
changed suffix for allocator aware functions + added allocator aware functions for UcxList
Mike Becker <universe@uap-core.de>
parents:
123
diff
changeset
|
121 | if (l) { |
8 | 122 | nl->next = l; |
123 | l->prev = nl; | |
124 | } | |
125 | return nl; | |
7
68091406d1cf
added dlist to makefile, implemented first functions, discarded some fails
Mike Becker <universe@uap-core.de>
parents:
4
diff
changeset
|
126 | } |
68091406d1cf
added dlist to makefile, implemented first functions, discarded some fails
Mike Becker <universe@uap-core.de>
parents:
4
diff
changeset
|
127 | |
122
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
121
diff
changeset
|
128 | UcxList *ucx_list_concat(UcxList *l1, UcxList *l2) { |
128
b79b1ce438dd
finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents:
125
diff
changeset
|
129 | if (l1) { |
122
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
121
diff
changeset
|
130 | UcxList *last = ucx_list_last(l1); |
8 | 131 | last->next = l2; |
172
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
161
diff
changeset
|
132 | if (l2) { |
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
161
diff
changeset
|
133 | l2->prev = last; |
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
161
diff
changeset
|
134 | } |
8 | 135 | return l1; |
128
b79b1ce438dd
finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents:
125
diff
changeset
|
136 | } else { |
b79b1ce438dd
finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents:
125
diff
changeset
|
137 | return l2; |
8 | 138 | } |
7
68091406d1cf
added dlist to makefile, implemented first functions, discarded some fails
Mike Becker <universe@uap-core.de>
parents:
4
diff
changeset
|
139 | } |
68091406d1cf
added dlist to makefile, implemented first functions, discarded some fails
Mike Becker <universe@uap-core.de>
parents:
4
diff
changeset
|
140 | |
122
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
121
diff
changeset
|
141 | UcxList *ucx_list_last(const UcxList *l) { |
7
68091406d1cf
added dlist to makefile, implemented first functions, discarded some fails
Mike Becker <universe@uap-core.de>
parents:
4
diff
changeset
|
142 | if (l == NULL) return NULL; |
68091406d1cf
added dlist to makefile, implemented first functions, discarded some fails
Mike Becker <universe@uap-core.de>
parents:
4
diff
changeset
|
143 | |
122
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
121
diff
changeset
|
144 | const UcxList *e = l; |
7
68091406d1cf
added dlist to makefile, implemented first functions, discarded some fails
Mike Becker <universe@uap-core.de>
parents:
4
diff
changeset
|
145 | while (e->next != NULL) { |
68091406d1cf
added dlist to makefile, implemented first functions, discarded some fails
Mike Becker <universe@uap-core.de>
parents:
4
diff
changeset
|
146 | e = e->next; |
68091406d1cf
added dlist to makefile, implemented first functions, discarded some fails
Mike Becker <universe@uap-core.de>
parents:
4
diff
changeset
|
147 | } |
122
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
121
diff
changeset
|
148 | return (UcxList*)e; |
7
68091406d1cf
added dlist to makefile, implemented first functions, discarded some fails
Mike Becker <universe@uap-core.de>
parents:
4
diff
changeset
|
149 | } |
68091406d1cf
added dlist to makefile, implemented first functions, discarded some fails
Mike Becker <universe@uap-core.de>
parents:
4
diff
changeset
|
150 | |
123
7fb0f74517c5
changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents:
122
diff
changeset
|
151 | ssize_t ucx_list_indexof(const UcxList *list, const UcxList *elem) { |
7fb0f74517c5
changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents:
122
diff
changeset
|
152 | ssize_t index = 0; |
7fb0f74517c5
changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents:
122
diff
changeset
|
153 | while (list) { |
7fb0f74517c5
changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents:
122
diff
changeset
|
154 | if (list == elem) { |
7fb0f74517c5
changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents:
122
diff
changeset
|
155 | return index; |
7fb0f74517c5
changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents:
122
diff
changeset
|
156 | } |
7fb0f74517c5
changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents:
122
diff
changeset
|
157 | list = list->next; |
7fb0f74517c5
changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents:
122
diff
changeset
|
158 | index++; |
7fb0f74517c5
changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents:
122
diff
changeset
|
159 | } |
7fb0f74517c5
changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents:
122
diff
changeset
|
160 | return -1; |
7fb0f74517c5
changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents:
122
diff
changeset
|
161 | } |
7fb0f74517c5
changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents:
122
diff
changeset
|
162 | |
172
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
161
diff
changeset
|
163 | UcxList *ucx_list_get(const UcxList *l, size_t index) { |
8 | 164 | if (l == NULL) return NULL; |
165 | ||
122
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
121
diff
changeset
|
166 | const UcxList *e = l; |
128
b79b1ce438dd
finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents:
125
diff
changeset
|
167 | while (e->next && index > 0) { |
8 | 168 | e = e->next; |
169 | index--; | |
170 | } | |
7
68091406d1cf
added dlist to makefile, implemented first functions, discarded some fails
Mike Becker <universe@uap-core.de>
parents:
4
diff
changeset
|
171 | |
122
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
121
diff
changeset
|
172 | return (UcxList*)(index == 0 ? e : NULL); |
7
68091406d1cf
added dlist to makefile, implemented first functions, discarded some fails
Mike Becker <universe@uap-core.de>
parents:
4
diff
changeset
|
173 | } |
68091406d1cf
added dlist to makefile, implemented first functions, discarded some fails
Mike Becker <universe@uap-core.de>
parents:
4
diff
changeset
|
174 | |
371
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
175 | ssize_t ucx_list_find(const UcxList *l, void *elem, |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
176 | cmp_func fnc, void *cmpdata) { |
123
7fb0f74517c5
changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents:
122
diff
changeset
|
177 | ssize_t index = 0; |
122
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
121
diff
changeset
|
178 | UCX_FOREACH(e, l) { |
128
b79b1ce438dd
finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents:
125
diff
changeset
|
179 | if (fnc) { |
b79b1ce438dd
finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents:
125
diff
changeset
|
180 | if (fnc(elem, e->data, cmpdata) == 0) { |
b79b1ce438dd
finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents:
125
diff
changeset
|
181 | return index; |
b79b1ce438dd
finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents:
125
diff
changeset
|
182 | } |
b79b1ce438dd
finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents:
125
diff
changeset
|
183 | } else { |
b79b1ce438dd
finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents:
125
diff
changeset
|
184 | if (elem == e->data) { |
b79b1ce438dd
finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents:
125
diff
changeset
|
185 | return index; |
b79b1ce438dd
finished documentation of UcxList
Mike Becker <universe@uap-core.de>
parents:
125
diff
changeset
|
186 | } |
87
bd444539cced
some fixes + ucx_(d)list_contains
Mike Becker <universe@uap-core.de>
parents:
73
diff
changeset
|
187 | } |
123
7fb0f74517c5
changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents:
122
diff
changeset
|
188 | index++; |
87
bd444539cced
some fixes + ucx_(d)list_contains
Mike Becker <universe@uap-core.de>
parents:
73
diff
changeset
|
189 | } |
123
7fb0f74517c5
changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents:
122
diff
changeset
|
190 | return -1; |
7fb0f74517c5
changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents:
122
diff
changeset
|
191 | } |
7fb0f74517c5
changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents:
122
diff
changeset
|
192 | |
371
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
193 | int ucx_list_contains(const UcxList *l, void *elem, |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
194 | cmp_func fnc, void *cmpdata) { |
123
7fb0f74517c5
changed signature of sstrncat + some documentation for UcxList + new features for UcxList
Mike Becker <universe@uap-core.de>
parents:
122
diff
changeset
|
195 | return ucx_list_find(l, elem, fnc, cmpdata) > -1; |
87
bd444539cced
some fixes + ucx_(d)list_contains
Mike Becker <universe@uap-core.de>
parents:
73
diff
changeset
|
196 | } |
bd444539cced
some fixes + ucx_(d)list_contains
Mike Becker <universe@uap-core.de>
parents:
73
diff
changeset
|
197 | |
122
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
121
diff
changeset
|
198 | size_t ucx_list_size(const UcxList *l) { |
7
68091406d1cf
added dlist to makefile, implemented first functions, discarded some fails
Mike Becker <universe@uap-core.de>
parents:
4
diff
changeset
|
199 | if (l == NULL) return 0; |
68091406d1cf
added dlist to makefile, implemented first functions, discarded some fails
Mike Becker <universe@uap-core.de>
parents:
4
diff
changeset
|
200 | |
122
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
121
diff
changeset
|
201 | const UcxList *e = l; |
7
68091406d1cf
added dlist to makefile, implemented first functions, discarded some fails
Mike Becker <universe@uap-core.de>
parents:
4
diff
changeset
|
202 | size_t s = 1; |
68091406d1cf
added dlist to makefile, implemented first functions, discarded some fails
Mike Becker <universe@uap-core.de>
parents:
4
diff
changeset
|
203 | while (e->next != NULL) { |
68091406d1cf
added dlist to makefile, implemented first functions, discarded some fails
Mike Becker <universe@uap-core.de>
parents:
4
diff
changeset
|
204 | e = e->next; |
68091406d1cf
added dlist to makefile, implemented first functions, discarded some fails
Mike Becker <universe@uap-core.de>
parents:
4
diff
changeset
|
205 | s++; |
68091406d1cf
added dlist to makefile, implemented first functions, discarded some fails
Mike Becker <universe@uap-core.de>
parents:
4
diff
changeset
|
206 | } |
68091406d1cf
added dlist to makefile, implemented first functions, discarded some fails
Mike Becker <universe@uap-core.de>
parents:
4
diff
changeset
|
207 | |
68091406d1cf
added dlist to makefile, implemented first functions, discarded some fails
Mike Becker <universe@uap-core.de>
parents:
4
diff
changeset
|
208 | return s; |
68091406d1cf
added dlist to makefile, implemented first functions, discarded some fails
Mike Becker <universe@uap-core.de>
parents:
4
diff
changeset
|
209 | } |
68091406d1cf
added dlist to makefile, implemented first functions, discarded some fails
Mike Becker <universe@uap-core.de>
parents:
4
diff
changeset
|
210 | |
335
872ae61c8945
fixes inappropriate size datatype in list merge sort
Mike Becker <universe@uap-core.de>
parents:
323
diff
changeset
|
211 | static UcxList *ucx_list_sort_merge(size_t length, |
253
e19825a1430a
removes unnecessary macros from ucx.h + removes the usage of restrict and _Bool completely, instead of defining macros
Mike Becker <universe@uap-core.de>
parents:
251
diff
changeset
|
212 | UcxList* ls, UcxList* le, UcxList* re, |
37
ec296899d12f
replaced qsort with natural merge sort
Mike Becker <universe@uap-core.de>
parents:
36
diff
changeset
|
213 | cmp_func fnc, void* data) { |
73
f15c7d6aebb9
lists now sort on heap to prevent stack overflows
Mike Becker <universe@uap-core.de>
parents:
69
diff
changeset
|
214 | |
122
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
121
diff
changeset
|
215 | UcxList** sorted = (UcxList**) malloc(sizeof(UcxList*)*length); |
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
121
diff
changeset
|
216 | UcxList *rc, *lc; |
35
fdabd1240b69
added mkdir for build directory to makefile + added qsort for list and dlist
Mike Becker <universe@uap-core.de>
parents:
31
diff
changeset
|
217 | |
67
27e67e725d35
added some qualifiers + removed pointer alias in mergesort
Mike Becker <universe@uap-core.de>
parents:
37
diff
changeset
|
218 | lc = ls; rc = le; |
335
872ae61c8945
fixes inappropriate size datatype in list merge sort
Mike Becker <universe@uap-core.de>
parents:
323
diff
changeset
|
219 | size_t n = 0; |
67
27e67e725d35
added some qualifiers + removed pointer alias in mergesort
Mike Becker <universe@uap-core.de>
parents:
37
diff
changeset
|
220 | while (lc && lc != le && rc != re) { |
37
ec296899d12f
replaced qsort with natural merge sort
Mike Becker <universe@uap-core.de>
parents:
36
diff
changeset
|
221 | if (fnc(lc->data, rc->data, data) <= 0) { |
ec296899d12f
replaced qsort with natural merge sort
Mike Becker <universe@uap-core.de>
parents:
36
diff
changeset
|
222 | sorted[n] = lc; |
ec296899d12f
replaced qsort with natural merge sort
Mike Becker <universe@uap-core.de>
parents:
36
diff
changeset
|
223 | lc = lc->next; |
ec296899d12f
replaced qsort with natural merge sort
Mike Becker <universe@uap-core.de>
parents:
36
diff
changeset
|
224 | } else { |
ec296899d12f
replaced qsort with natural merge sort
Mike Becker <universe@uap-core.de>
parents:
36
diff
changeset
|
225 | sorted[n] = rc; |
ec296899d12f
replaced qsort with natural merge sort
Mike Becker <universe@uap-core.de>
parents:
36
diff
changeset
|
226 | rc = rc->next; |
35
fdabd1240b69
added mkdir for build directory to makefile + added qsort for list and dlist
Mike Becker <universe@uap-core.de>
parents:
31
diff
changeset
|
227 | } |
37
ec296899d12f
replaced qsort with natural merge sort
Mike Becker <universe@uap-core.de>
parents:
36
diff
changeset
|
228 | n++; |
ec296899d12f
replaced qsort with natural merge sort
Mike Becker <universe@uap-core.de>
parents:
36
diff
changeset
|
229 | } |
67
27e67e725d35
added some qualifiers + removed pointer alias in mergesort
Mike Becker <universe@uap-core.de>
parents:
37
diff
changeset
|
230 | while (lc && lc != le) { |
37
ec296899d12f
replaced qsort with natural merge sort
Mike Becker <universe@uap-core.de>
parents:
36
diff
changeset
|
231 | sorted[n] = lc; |
ec296899d12f
replaced qsort with natural merge sort
Mike Becker <universe@uap-core.de>
parents:
36
diff
changeset
|
232 | lc = lc->next; |
ec296899d12f
replaced qsort with natural merge sort
Mike Becker <universe@uap-core.de>
parents:
36
diff
changeset
|
233 | n++; |
ec296899d12f
replaced qsort with natural merge sort
Mike Becker <universe@uap-core.de>
parents:
36
diff
changeset
|
234 | } |
67
27e67e725d35
added some qualifiers + removed pointer alias in mergesort
Mike Becker <universe@uap-core.de>
parents:
37
diff
changeset
|
235 | while (rc && rc != re) { |
37
ec296899d12f
replaced qsort with natural merge sort
Mike Becker <universe@uap-core.de>
parents:
36
diff
changeset
|
236 | sorted[n] = rc; |
ec296899d12f
replaced qsort with natural merge sort
Mike Becker <universe@uap-core.de>
parents:
36
diff
changeset
|
237 | rc = rc->next; |
ec296899d12f
replaced qsort with natural merge sort
Mike Becker <universe@uap-core.de>
parents:
36
diff
changeset
|
238 | n++; |
35
fdabd1240b69
added mkdir for build directory to makefile + added qsort for list and dlist
Mike Becker <universe@uap-core.de>
parents:
31
diff
changeset
|
239 | } |
fdabd1240b69
added mkdir for build directory to makefile + added qsort for list and dlist
Mike Becker <universe@uap-core.de>
parents:
31
diff
changeset
|
240 | |
37
ec296899d12f
replaced qsort with natural merge sort
Mike Becker <universe@uap-core.de>
parents:
36
diff
changeset
|
241 | // Update pointer |
ec296899d12f
replaced qsort with natural merge sort
Mike Becker <universe@uap-core.de>
parents:
36
diff
changeset
|
242 | sorted[0]->prev = NULL; |
ec296899d12f
replaced qsort with natural merge sort
Mike Becker <universe@uap-core.de>
parents:
36
diff
changeset
|
243 | for (int i = 0 ; i < length-1 ; i++) { |
ec296899d12f
replaced qsort with natural merge sort
Mike Becker <universe@uap-core.de>
parents:
36
diff
changeset
|
244 | sorted[i]->next = sorted[i+1]; |
ec296899d12f
replaced qsort with natural merge sort
Mike Becker <universe@uap-core.de>
parents:
36
diff
changeset
|
245 | sorted[i+1]->prev = sorted[i]; |
ec296899d12f
replaced qsort with natural merge sort
Mike Becker <universe@uap-core.de>
parents:
36
diff
changeset
|
246 | } |
ec296899d12f
replaced qsort with natural merge sort
Mike Becker <universe@uap-core.de>
parents:
36
diff
changeset
|
247 | sorted[length-1]->next = NULL; |
35
fdabd1240b69
added mkdir for build directory to makefile + added qsort for list and dlist
Mike Becker <universe@uap-core.de>
parents:
31
diff
changeset
|
248 | |
122
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
121
diff
changeset
|
249 | UcxList *ret = sorted[0]; |
73
f15c7d6aebb9
lists now sort on heap to prevent stack overflows
Mike Becker <universe@uap-core.de>
parents:
69
diff
changeset
|
250 | free(sorted); |
69
fb59270b1de3
made the code work with VC++ compiler (use make CONF=windows)
Mike Becker <universe@uap-core.de>
parents:
67
diff
changeset
|
251 | return ret; |
35
fdabd1240b69
added mkdir for build directory to makefile + added qsort for list and dlist
Mike Becker <universe@uap-core.de>
parents:
31
diff
changeset
|
252 | } |
fdabd1240b69
added mkdir for build directory to makefile + added qsort for list and dlist
Mike Becker <universe@uap-core.de>
parents:
31
diff
changeset
|
253 | |
122
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
121
diff
changeset
|
254 | UcxList *ucx_list_sort(UcxList *l, cmp_func fnc, void *data) { |
35
fdabd1240b69
added mkdir for build directory to makefile + added qsort for list and dlist
Mike Becker <universe@uap-core.de>
parents:
31
diff
changeset
|
255 | if (l == NULL) { |
fdabd1240b69
added mkdir for build directory to makefile + added qsort for list and dlist
Mike Becker <universe@uap-core.de>
parents:
31
diff
changeset
|
256 | return NULL; |
fdabd1240b69
added mkdir for build directory to makefile + added qsort for list and dlist
Mike Becker <universe@uap-core.de>
parents:
31
diff
changeset
|
257 | } |
37
ec296899d12f
replaced qsort with natural merge sort
Mike Becker <universe@uap-core.de>
parents:
36
diff
changeset
|
258 | |
122
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
121
diff
changeset
|
259 | UcxList *lc; |
335
872ae61c8945
fixes inappropriate size datatype in list merge sort
Mike Becker <universe@uap-core.de>
parents:
323
diff
changeset
|
260 | size_t ln = 1; |
37
ec296899d12f
replaced qsort with natural merge sort
Mike Becker <universe@uap-core.de>
parents:
36
diff
changeset
|
261 | |
253
e19825a1430a
removes unnecessary macros from ucx.h + removes the usage of restrict and _Bool completely, instead of defining macros
Mike Becker <universe@uap-core.de>
parents:
251
diff
changeset
|
262 | UcxList *ls = l, *le, *re; |
172
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
161
diff
changeset
|
263 | |
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
161
diff
changeset
|
264 | // check how many elements are already sorted |
37
ec296899d12f
replaced qsort with natural merge sort
Mike Becker <universe@uap-core.de>
parents:
36
diff
changeset
|
265 | lc = ls; |
ec296899d12f
replaced qsort with natural merge sort
Mike Becker <universe@uap-core.de>
parents:
36
diff
changeset
|
266 | while (lc->next != NULL && fnc(lc->next->data, lc->data, data) > 0) { |
ec296899d12f
replaced qsort with natural merge sort
Mike Becker <universe@uap-core.de>
parents:
36
diff
changeset
|
267 | lc = lc->next; |
ec296899d12f
replaced qsort with natural merge sort
Mike Becker <universe@uap-core.de>
parents:
36
diff
changeset
|
268 | ln++; |
ec296899d12f
replaced qsort with natural merge sort
Mike Becker <universe@uap-core.de>
parents:
36
diff
changeset
|
269 | } |
ec296899d12f
replaced qsort with natural merge sort
Mike Becker <universe@uap-core.de>
parents:
36
diff
changeset
|
270 | le = lc->next; |
ec296899d12f
replaced qsort with natural merge sort
Mike Becker <universe@uap-core.de>
parents:
36
diff
changeset
|
271 | |
67
27e67e725d35
added some qualifiers + removed pointer alias in mergesort
Mike Becker <universe@uap-core.de>
parents:
37
diff
changeset
|
272 | if (le == NULL) { |
37
ec296899d12f
replaced qsort with natural merge sort
Mike Becker <universe@uap-core.de>
parents:
36
diff
changeset
|
273 | return l; // this list is already sorted :) |
ec296899d12f
replaced qsort with natural merge sort
Mike Becker <universe@uap-core.de>
parents:
36
diff
changeset
|
274 | } else { |
122
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
121
diff
changeset
|
275 | UcxList *rc; |
335
872ae61c8945
fixes inappropriate size datatype in list merge sort
Mike Becker <universe@uap-core.de>
parents:
323
diff
changeset
|
276 | size_t rn = 1; |
67
27e67e725d35
added some qualifiers + removed pointer alias in mergesort
Mike Becker <universe@uap-core.de>
parents:
37
diff
changeset
|
277 | rc = le; |
172
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
161
diff
changeset
|
278 | // skip already sorted elements |
37
ec296899d12f
replaced qsort with natural merge sort
Mike Becker <universe@uap-core.de>
parents:
36
diff
changeset
|
279 | while (rc->next != NULL && fnc(rc->next->data, rc->data, data) > 0) { |
ec296899d12f
replaced qsort with natural merge sort
Mike Becker <universe@uap-core.de>
parents:
36
diff
changeset
|
280 | rc = rc->next; |
ec296899d12f
replaced qsort with natural merge sort
Mike Becker <universe@uap-core.de>
parents:
36
diff
changeset
|
281 | rn++; |
ec296899d12f
replaced qsort with natural merge sort
Mike Becker <universe@uap-core.de>
parents:
36
diff
changeset
|
282 | } |
ec296899d12f
replaced qsort with natural merge sort
Mike Becker <universe@uap-core.de>
parents:
36
diff
changeset
|
283 | re = rc->next; |
ec296899d12f
replaced qsort with natural merge sort
Mike Becker <universe@uap-core.de>
parents:
36
diff
changeset
|
284 | |
ec296899d12f
replaced qsort with natural merge sort
Mike Becker <universe@uap-core.de>
parents:
36
diff
changeset
|
285 | // {ls,...,le->prev} and {rs,...,re->prev} are sorted - merge them |
122
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
121
diff
changeset
|
286 | UcxList *sorted = ucx_list_sort_merge(ln+rn, |
67
27e67e725d35
added some qualifiers + removed pointer alias in mergesort
Mike Becker <universe@uap-core.de>
parents:
37
diff
changeset
|
287 | ls, le, re, |
37
ec296899d12f
replaced qsort with natural merge sort
Mike Becker <universe@uap-core.de>
parents:
36
diff
changeset
|
288 | fnc, data); |
172
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
161
diff
changeset
|
289 | |
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
161
diff
changeset
|
290 | // Something left? Sort it! |
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
161
diff
changeset
|
291 | size_t remainder_length = ucx_list_size(re); |
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
161
diff
changeset
|
292 | if (remainder_length > 0) { |
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
161
diff
changeset
|
293 | UcxList *remainder = ucx_list_sort(re, fnc, data); |
37
ec296899d12f
replaced qsort with natural merge sort
Mike Becker <universe@uap-core.de>
parents:
36
diff
changeset
|
294 | |
172
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
161
diff
changeset
|
295 | // merge sorted list with (also sorted) remainder |
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
161
diff
changeset
|
296 | l = ucx_list_sort_merge(ln+rn+remainder_length, |
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
161
diff
changeset
|
297 | sorted, remainder, NULL, fnc, data); |
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
161
diff
changeset
|
298 | } else { |
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
161
diff
changeset
|
299 | // no remainder - we've got our sorted list |
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
161
diff
changeset
|
300 | l = sorted; |
7084e8e8433c
refactoring of list tests + some bug fixes
Mike Becker <universe@uap-core.de>
parents:
161
diff
changeset
|
301 | } |
37
ec296899d12f
replaced qsort with natural merge sort
Mike Becker <universe@uap-core.de>
parents:
36
diff
changeset
|
302 | |
35
fdabd1240b69
added mkdir for build directory to makefile + added qsort for list and dlist
Mike Becker <universe@uap-core.de>
parents:
31
diff
changeset
|
303 | return l; |
fdabd1240b69
added mkdir for build directory to makefile + added qsort for list and dlist
Mike Becker <universe@uap-core.de>
parents:
31
diff
changeset
|
304 | } |
fdabd1240b69
added mkdir for build directory to makefile + added qsort for list and dlist
Mike Becker <universe@uap-core.de>
parents:
31
diff
changeset
|
305 | } |
fdabd1240b69
added mkdir for build directory to makefile + added qsort for list and dlist
Mike Becker <universe@uap-core.de>
parents:
31
diff
changeset
|
306 | |
122
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
121
diff
changeset
|
307 | UcxList *ucx_list_first(const UcxList *l) { |
125
fca8efb122de
changed suffix for allocator aware functions + added allocator aware functions for UcxList
Mike Becker <universe@uap-core.de>
parents:
123
diff
changeset
|
308 | if (!l) { |
fca8efb122de
changed suffix for allocator aware functions + added allocator aware functions for UcxList
Mike Becker <universe@uap-core.de>
parents:
123
diff
changeset
|
309 | return NULL; |
fca8efb122de
changed suffix for allocator aware functions + added allocator aware functions for UcxList
Mike Becker <universe@uap-core.de>
parents:
123
diff
changeset
|
310 | } |
7
68091406d1cf
added dlist to makefile, implemented first functions, discarded some fails
Mike Becker <universe@uap-core.de>
parents:
4
diff
changeset
|
311 | |
122
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
121
diff
changeset
|
312 | const UcxList *e = l; |
125
fca8efb122de
changed suffix for allocator aware functions + added allocator aware functions for UcxList
Mike Becker <universe@uap-core.de>
parents:
123
diff
changeset
|
313 | while (e->prev) { |
8 | 314 | e = e->prev; |
315 | } | |
122
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
121
diff
changeset
|
316 | return (UcxList *)e; |
13 | 317 | } |
22
76cdd8209f1f
added ucx_dlist_remove and tests + fixed makefile error
Mike Becker <universe@uap-core.de>
parents:
18
diff
changeset
|
318 | |
122
540d99722f1f
removal of single linked list implemenation - step 2: renamed UcxDlist to UcxList (new single implementation)
Mike Becker <universe@uap-core.de>
parents:
121
diff
changeset
|
319 | UcxList *ucx_list_remove(UcxList *l, UcxList *e) { |
125
fca8efb122de
changed suffix for allocator aware functions + added allocator aware functions for UcxList
Mike Becker <universe@uap-core.de>
parents:
123
diff
changeset
|
320 | return ucx_list_remove_a(ucx_default_allocator(), l, e); |
fca8efb122de
changed suffix for allocator aware functions + added allocator aware functions for UcxList
Mike Becker <universe@uap-core.de>
parents:
123
diff
changeset
|
321 | } |
fca8efb122de
changed suffix for allocator aware functions + added allocator aware functions for UcxList
Mike Becker <universe@uap-core.de>
parents:
123
diff
changeset
|
322 | |
fca8efb122de
changed suffix for allocator aware functions + added allocator aware functions for UcxList
Mike Becker <universe@uap-core.de>
parents:
123
diff
changeset
|
323 | UcxList *ucx_list_remove_a(UcxAllocator *alloc, UcxList *l, UcxList *e) { |
161
1031dd910f8e
fixed ucx_list_remove crashing when removing the last element of a list
Mike Becker <universe@uap-core.de>
parents:
128
diff
changeset
|
324 | if (l == e) { |
1031dd910f8e
fixed ucx_list_remove crashing when removing the last element of a list
Mike Becker <universe@uap-core.de>
parents:
128
diff
changeset
|
325 | l = e->next; |
1031dd910f8e
fixed ucx_list_remove crashing when removing the last element of a list
Mike Becker <universe@uap-core.de>
parents:
128
diff
changeset
|
326 | } |
1031dd910f8e
fixed ucx_list_remove crashing when removing the last element of a list
Mike Becker <universe@uap-core.de>
parents:
128
diff
changeset
|
327 | |
1031dd910f8e
fixed ucx_list_remove crashing when removing the last element of a list
Mike Becker <universe@uap-core.de>
parents:
128
diff
changeset
|
328 | if (e->next) { |
22
76cdd8209f1f
added ucx_dlist_remove and tests + fixed makefile error
Mike Becker <universe@uap-core.de>
parents:
18
diff
changeset
|
329 | e->next->prev = e->prev; |
76cdd8209f1f
added ucx_dlist_remove and tests + fixed makefile error
Mike Becker <universe@uap-core.de>
parents:
18
diff
changeset
|
330 | } |
161
1031dd910f8e
fixed ucx_list_remove crashing when removing the last element of a list
Mike Becker <universe@uap-core.de>
parents:
128
diff
changeset
|
331 | |
1031dd910f8e
fixed ucx_list_remove crashing when removing the last element of a list
Mike Becker <universe@uap-core.de>
parents:
128
diff
changeset
|
332 | if (e->prev) { |
1031dd910f8e
fixed ucx_list_remove crashing when removing the last element of a list
Mike Becker <universe@uap-core.de>
parents:
128
diff
changeset
|
333 | e->prev->next = e->next; |
1031dd910f8e
fixed ucx_list_remove crashing when removing the last element of a list
Mike Becker <universe@uap-core.de>
parents:
128
diff
changeset
|
334 | } |
1031dd910f8e
fixed ucx_list_remove crashing when removing the last element of a list
Mike Becker <universe@uap-core.de>
parents:
128
diff
changeset
|
335 | |
173
31a8682fffb7
fixed some sstring issues + added allocator macros
Mike Becker <universe@uap-core.de>
parents:
172
diff
changeset
|
336 | alfree(alloc, e); |
22
76cdd8209f1f
added ucx_dlist_remove and tests + fixed makefile error
Mike Becker <universe@uap-core.de>
parents:
18
diff
changeset
|
337 | return l; |
76cdd8209f1f
added ucx_dlist_remove and tests + fixed makefile error
Mike Becker <universe@uap-core.de>
parents:
18
diff
changeset
|
338 | } |
371
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
339 | |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
340 | |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
341 | static UcxList* ucx_list_setoperation_a(UcxAllocator *allocator, |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
342 | UcxList const *left, UcxList const *right, |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
343 | cmp_func cmpfnc, void* cmpdata, |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
344 | copy_func cpfnc, void* cpdata, |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
345 | int op) { |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
346 | |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
347 | UcxList *res = NULL; |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
348 | UcxList *cur = NULL; |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
349 | const UcxList *src = left; |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
350 | |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
351 | do { |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
352 | UCX_FOREACH(node, src) { |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
353 | void* elem = node->data; |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
354 | if ( |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
355 | (op == 0 && !ucx_list_contains(res, elem, cmpfnc, cmpdata)) || |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
356 | (op == 1 && ucx_list_contains(right, elem, cmpfnc, cmpdata)) || |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
357 | (op == 2 && !ucx_list_contains(right, elem, cmpfnc, cmpdata))) { |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
358 | UcxList *nl = almalloc(allocator, sizeof(UcxList)); |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
359 | nl->prev = cur; |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
360 | nl->next = NULL; |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
361 | if (cpfnc) { |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
362 | nl->data = cpfnc(elem, cpdata); |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
363 | } else { |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
364 | nl->data = elem; |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
365 | } |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
366 | if (cur != NULL) |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
367 | cur->next = nl; |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
368 | cur = nl; |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
369 | if (res == NULL) |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
370 | res = cur; |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
371 | } |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
372 | } |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
373 | if (op == 0 && src == left) |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
374 | src = right; |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
375 | else |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
376 | src = NULL; |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
377 | } while (src != NULL); |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
378 | |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
379 | return res; |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
380 | } |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
381 | |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
382 | UcxList* ucx_list_union(UcxList const *left, UcxList const *right, |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
383 | cmp_func cmpfnc, void* cmpdata, |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
384 | copy_func cpfnc, void* cpdata) { |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
385 | return ucx_list_union_a(ucx_default_allocator(), |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
386 | left, right, cmpfnc, cmpdata, cpfnc, cpdata); |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
387 | } |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
388 | |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
389 | UcxList* ucx_list_union_a(UcxAllocator *allocator, |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
390 | UcxList const *left, UcxList const *right, |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
391 | cmp_func cmpfnc, void* cmpdata, |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
392 | copy_func cpfnc, void* cpdata) { |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
393 | |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
394 | return ucx_list_setoperation_a(allocator, left, right, |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
395 | cmpfnc, cmpdata, cpfnc, cpdata, 0); |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
396 | } |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
397 | |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
398 | UcxList* ucx_list_intersection(UcxList const *left, UcxList const *right, |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
399 | cmp_func cmpfnc, void* cmpdata, |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
400 | copy_func cpfnc, void* cpdata) { |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
401 | return ucx_list_intersection_a(ucx_default_allocator(), left, right, |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
402 | cmpfnc, cmpdata, cpfnc, cpdata); |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
403 | } |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
404 | |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
405 | UcxList* ucx_list_intersection_a(UcxAllocator *allocator, |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
406 | UcxList const *left, UcxList const *right, |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
407 | cmp_func cmpfnc, void* cmpdata, |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
408 | copy_func cpfnc, void* cpdata) { |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
409 | |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
410 | return ucx_list_setoperation_a(allocator, left, right, |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
411 | cmpfnc, cmpdata, cpfnc, cpdata, 1); |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
412 | } |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
413 | |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
414 | UcxList* ucx_list_difference(UcxList const *left, UcxList const *right, |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
415 | cmp_func cmpfnc, void* cmpdata, |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
416 | copy_func cpfnc, void* cpdata) { |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
417 | return ucx_list_difference_a(ucx_default_allocator(), left, right, |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
418 | cmpfnc, cmpdata, cpfnc, cpdata); |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
419 | } |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
420 | |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
421 | UcxList* ucx_list_difference_a(UcxAllocator *allocator, |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
422 | UcxList const *left, UcxList const *right, |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
423 | cmp_func cmpfnc, void* cmpdata, |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
424 | copy_func cpfnc, void* cpdata) { |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
425 | |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
426 | return ucx_list_setoperation_a(allocator, left, right, |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
427 | cmpfnc, cmpdata, cpfnc, cpdata, 2); |
365b24f20f98
adds set operations to UcxList
Mike Becker <universe@uap-core.de>
parents:
335
diff
changeset
|
428 | } |