Thu, 04 Jul 2019 20:07:31 +0200
adds array interface and tests
universe@103 | 1 | /* |
universe@103 | 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
universe@103 | 3 | * |
universe@334 | 4 | * Copyright 2019 Mike Becker, Olaf Wintermann All rights reserved. |
universe@103 | 5 | * |
universe@103 | 6 | * Redistribution and use in source and binary forms, with or without |
universe@103 | 7 | * modification, are permitted provided that the following conditions are met: |
universe@103 | 8 | * |
universe@103 | 9 | * 1. Redistributions of source code must retain the above copyright |
universe@103 | 10 | * notice, this list of conditions and the following disclaimer. |
universe@103 | 11 | * |
universe@103 | 12 | * 2. Redistributions in binary form must reproduce the above copyright |
universe@103 | 13 | * notice, this list of conditions and the following disclaimer in the |
universe@103 | 14 | * documentation and/or other materials provided with the distribution. |
universe@103 | 15 | * |
universe@103 | 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
universe@103 | 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
universe@103 | 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
universe@103 | 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
universe@103 | 20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
universe@103 | 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
universe@103 | 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
universe@103 | 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
universe@103 | 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
universe@103 | 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
universe@103 | 26 | * POSSIBILITY OF SUCH DAMAGE. |
universe@103 | 27 | */ |
universe@103 | 28 | |
universe@334 | 29 | #include "ucx/array.h" |
universe@4 | 30 | |
universe@334 | 31 | |
universe@334 | 32 | UcxArray ucx_array_new(size_t capacity, size_t elemsize) { |
universe@334 | 33 | return ucx_array_new_a(capacity, elemsize, ucx_default_allocator()); |
universe@125 | 34 | } |
universe@125 | 35 | |
universe@334 | 36 | UcxArray ucx_array_new_a(size_t capacity, size_t elemsize, |
universe@334 | 37 | UcxAllocator* allocator) { |
universe@334 | 38 | UcxArray array; |
universe@334 | 39 | |
universe@334 | 40 | return array; |
universe@18 | 41 | } |
universe@18 | 42 | |
universe@334 | 43 | UcxArray ucx_array_clone(UcxArray array) { |
universe@334 | 44 | UcxArray clone; |
universe@18 | 45 | |
universe@334 | 46 | return clone; |
universe@18 | 47 | } |
universe@18 | 48 | |
universe@334 | 49 | int ucx_array_equals(UcxArray array1, UcxArray array2, |
universe@334 | 50 | cmp_func cmpfnc, void* data) { |
universe@334 | 51 | |
universe@334 | 52 | return 1; |
universe@125 | 53 | } |
universe@125 | 54 | |
universe@334 | 55 | void ucx_array_free(UcxArray *array) { |
universe@334 | 56 | |
universe@8 | 57 | } |
universe@8 | 58 | |
universe@334 | 59 | int ucx_array_append(UcxArray *array, void *data) { |
universe@334 | 60 | return 1; |
universe@211 | 61 | } |
universe@211 | 62 | |
universe@334 | 63 | int ucx_array_prepend(UcxArray *array, void *data) { |
universe@334 | 64 | return 1; |
universe@125 | 65 | } |
universe@125 | 66 | |
universe@334 | 67 | int ucx_array_concat(UcxArray *array1, const UcxArray *array2) { |
universe@334 | 68 | return 1; |
universe@7 | 69 | } |
universe@7 | 70 | |
universe@334 | 71 | void *ucx_array_at(UcxArray array, size_t index) { |
universe@334 | 72 | return NULL; |
universe@125 | 73 | } |
universe@125 | 74 | |
universe@334 | 75 | size_t ucx_array_find(UcxArray array, void *elem, cmp_func cmpfnc, void *data) { |
universe@7 | 76 | |
universe@334 | 77 | return 0; |
universe@7 | 78 | } |
universe@7 | 79 | |
universe@334 | 80 | int ucx_array_contains(UcxArray array, void *elem, cmp_func cmpfnc, void *data) { |
universe@334 | 81 | return ucx_array_find(array, elem, cmpfnc, data) != array.size; |
universe@7 | 82 | } |
universe@7 | 83 | |
universe@334 | 84 | int ucx_array_sort(UcxArray array, cmp_func cmpfnc, void *data) { |
universe@334 | 85 | return 1; |
universe@7 | 86 | } |
universe@7 | 87 | |
universe@334 | 88 | void ucx_array_remove(UcxArray *array, size_t index) { |
universe@334 | 89 | |
universe@123 | 90 | } |
universe@123 | 91 | |
universe@334 | 92 | void ucx_array_remove_fast(UcxArray *array, size_t index) { |
universe@7 | 93 | |
universe@7 | 94 | } |
universe@7 | 95 | |
universe@334 | 96 | int ucx_array_shrink(UcxArray* array) { |
universe@334 | 97 | return 1; |
universe@123 | 98 | } |
universe@123 | 99 | |
universe@334 | 100 | int ucx_array_resize(UcxArray* array, size_t capacity) { |
universe@334 | 101 | return 1; |
universe@87 | 102 | } |
universe@87 | 103 | |
universe@334 | 104 | int ucx_array_reserve(UcxArray* array, size_t capacity) { |
universe@334 | 105 | return 1; |
universe@7 | 106 | } |
universe@7 | 107 |