2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
\r
4 * Copyright 2023 Mike Becker, Olaf Wintermann All rights reserved.
\r
6 * Redistribution and use in source and binary forms, with or without
\r
7 * modification, are permitted provided that the following conditions are met:
\r
9 * 1. Redistributions of source code must retain the above copyright
\r
10 * notice, this list of conditions and the following disclaimer.
\r
12 * 2. Redistributions in binary form must reproduce the above copyright
\r
13 * notice, this list of conditions and the following disclaimer in the
\r
14 * documentation and/or other materials provided with the distribution.
\r
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
\r
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
\r
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
\r
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
\r
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
\r
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
\r
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
\r
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
\r
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
\r
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
\r
26 * POSSIBILITY OF SUCH DAMAGE.
\r
32 // <editor-fold desc="empty map implementation">
\r
34 static void cx_empty_map_noop(__attribute__((__unused__)) CxMap *map) {
\r
35 // this is a noop, but MUST be implemented
\r
38 static void *cx_empty_map_get(
\r
39 __attribute__((__unused__)) CxMap const *map,
\r
40 __attribute__((__unused__)) CxHashKey key
\r
45 static bool cx_empty_map_iter_valid(__attribute__((__unused__)) void const *iter) {
\r
49 static CxIterator cx_empty_map_iterator(
\r
50 struct cx_map_s const *map,
\r
51 __attribute__((__unused__)) enum cx_map_iterator_type type
\r
53 CxIterator iter = {0};
\r
54 iter.src_handle = map;
\r
55 iter.base.valid = cx_empty_map_iter_valid;
\r
59 static struct cx_map_class_s cx_empty_map_class = {
\r
65 cx_empty_map_iterator
\r
68 CxMap cx_empty_map = {
\r
80 CxMap *const cxEmptyMap = &cx_empty_map;
\r
84 CxMutIterator cxMapMutIteratorValues(CxMap *map) {
\r
85 CxIterator it = map->cl->iterator(map, CX_MAP_ITERATOR_VALUES);
\r
86 it.base.mutating = true;
\r
88 // we know the iterators share the same memory layout
\r
90 memcpy(&iter, &it, sizeof(CxMutIterator));
\r
94 CxMutIterator cxMapMutIteratorKeys(CxMap *map) {
\r
95 CxIterator it = map->cl->iterator(map, CX_MAP_ITERATOR_KEYS);
\r
96 it.base.mutating = true;
\r
98 // we know the iterators share the same memory layout
\r
100 memcpy(&iter, &it, sizeof(CxMutIterator));
\r
104 CxMutIterator cxMapMutIterator(CxMap *map) {
\r
105 CxIterator it = map->cl->iterator(map, CX_MAP_ITERATOR_PAIRS);
\r
106 it.base.mutating = true;
\r
108 // we know the iterators share the same memory layout
\r
109 CxMutIterator iter;
\r
110 memcpy(&iter, &it, sizeof(CxMutIterator));
\r