src/list.c

Tue, 05 Oct 2021 11:19:32 +0200

author
Mike Becker <universe@uap-core.de>
date
Tue, 05 Oct 2021 11:19:32 +0200
changeset 460
e075009b33b7
parent 439
9a5adedd6de6
permissions
-rw-r--r--

remove convenience macros

Users should write their own wrappers s.t. the type
information does not have to be repeated on every
call site.

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 *
390
d345541018fa starts ucx 3.0 development
Mike Becker <universe@uap-core.de>
parents: 371
diff changeset
4 * Copyright 2021 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
390
d345541018fa starts ucx 3.0 development
Mike Becker <universe@uap-core.de>
parents: 371
diff changeset
29 #include "cx/list.h"
398
8d506ed6c1c0 adds first draft for linked list implementation
Mike Becker <universe@uap-core.de>
parents: 390
diff changeset
30
8d506ed6c1c0 adds first draft for linked list implementation
Mike Becker <universe@uap-core.de>
parents: 390
diff changeset
31 int cxListAdd(CxList list, void *elem) {
435
0fe204d50f54 change inheritance model for lists
Mike Becker <universe@uap-core.de>
parents: 404
diff changeset
32 return list->cl->add(list, elem);
398
8d506ed6c1c0 adds first draft for linked list implementation
Mike Becker <universe@uap-core.de>
parents: 390
diff changeset
33 }
8d506ed6c1c0 adds first draft for linked list implementation
Mike Becker <universe@uap-core.de>
parents: 390
diff changeset
34
8d506ed6c1c0 adds first draft for linked list implementation
Mike Becker <universe@uap-core.de>
parents: 390
diff changeset
35 int cxListInsert(CxList list, size_t index, void *elem) {
435
0fe204d50f54 change inheritance model for lists
Mike Becker <universe@uap-core.de>
parents: 404
diff changeset
36 return list->cl->insert(list, index, elem);
398
8d506ed6c1c0 adds first draft for linked list implementation
Mike Becker <universe@uap-core.de>
parents: 390
diff changeset
37 }
8d506ed6c1c0 adds first draft for linked list implementation
Mike Becker <universe@uap-core.de>
parents: 390
diff changeset
38
438
cd3069757010 add function cx_linked_list_at()
Mike Becker <universe@uap-core.de>
parents: 435
diff changeset
39 int cxListRemove(CxList list, size_t index) {
435
0fe204d50f54 change inheritance model for lists
Mike Becker <universe@uap-core.de>
parents: 404
diff changeset
40 return list->cl->remove(list, index);
398
8d506ed6c1c0 adds first draft for linked list implementation
Mike Becker <universe@uap-core.de>
parents: 390
diff changeset
41 }
8d506ed6c1c0 adds first draft for linked list implementation
Mike Becker <universe@uap-core.de>
parents: 390
diff changeset
42
439
9a5adedd6de6 add high-level function cxListAt()
Mike Becker <universe@uap-core.de>
parents: 438
diff changeset
43 void *cxListAt(CxList list, size_t index) {
9a5adedd6de6 add high-level function cxListAt()
Mike Becker <universe@uap-core.de>
parents: 438
diff changeset
44 return list->cl->at(list, index);
9a5adedd6de6 add high-level function cxListAt()
Mike Becker <universe@uap-core.de>
parents: 438
diff changeset
45 }
9a5adedd6de6 add high-level function cxListAt()
Mike Becker <universe@uap-core.de>
parents: 438
diff changeset
46
398
8d506ed6c1c0 adds first draft for linked list implementation
Mike Becker <universe@uap-core.de>
parents: 390
diff changeset
47 size_t cxListFind(CxList list, void *elem) {
435
0fe204d50f54 change inheritance model for lists
Mike Becker <universe@uap-core.de>
parents: 404
diff changeset
48 return list->cl->find(list, elem);
398
8d506ed6c1c0 adds first draft for linked list implementation
Mike Becker <universe@uap-core.de>
parents: 390
diff changeset
49 }
404
86ebc3745e62 adds cxListLast
Mike Becker <universe@uap-core.de>
parents: 401
diff changeset
50
86ebc3745e62 adds cxListLast
Mike Becker <universe@uap-core.de>
parents: 401
diff changeset
51 void *cxListLast(CxList list) {
435
0fe204d50f54 change inheritance model for lists
Mike Becker <universe@uap-core.de>
parents: 404
diff changeset
52 return list->cl->last(list);
404
86ebc3745e62 adds cxListLast
Mike Becker <universe@uap-core.de>
parents: 401
diff changeset
53 }

mercurial