Sat, 25 Jan 2025 13:44:24 +0100
add marker to every incomplete page
relates to #451
1143
0559812df10c
assign proper names to the documentation topics
Mike Becker <universe@uap-core.de>
parents:
1142
diff
changeset
|
1 | # Map Interface |
1141 | 2 | |
1146
151c057faf7c
add marker to every incomplete page
Mike Becker <universe@uap-core.de>
parents:
1143
diff
changeset
|
3 | <warning> |
151c057faf7c
add marker to every incomplete page
Mike Becker <universe@uap-core.de>
parents:
1143
diff
changeset
|
4 | Outdated - Rewrite! |
151c057faf7c
add marker to every incomplete page
Mike Becker <universe@uap-core.de>
parents:
1143
diff
changeset
|
5 | </warning> |
151c057faf7c
add marker to every incomplete page
Mike Becker <universe@uap-core.de>
parents:
1143
diff
changeset
|
6 | |
1141 | 7 | Similar to the list interface, the map interface provides a common API for implementing maps. |
8 | There are some minor subtle differences, though. | |
9 | ||
10 | First, the `remove` method is not always a destructive removal. | |
11 | Instead, the last argument is a Boolean that indicates whether the element shall be destroyed or returned. | |
12 | ```c | |
13 | void *(*remove)(CxMap *map, CxHashKey key, bool destroy); | |
14 | ``` | |
15 | When you implement this method, you are either supposed to invoke the destructors and return `NULL`, | |
16 | or just remove the element from the map and return it. | |
17 | ||
18 | Secondly, the iterator method is a bit more complete. The signature is as follows: | |
19 | ```c | |
20 | CxIterator (*iterator)(const CxMap *map, enum cx_map_iterator_type type); | |
21 | ``` | |
22 | There are three map iterator types: for values, for keys, for pairs. | |
23 | Depending on the iterator type requested, you need to create an iterator with the correct methods that | |
24 | return the requested thing. | |
25 | There are no automatic checks to enforce this - it's completely up to you. | |
26 | If you need inspiration on how to do that, check the hash map implementation that comes with UCX. | |
1142
9437530176bc
add symbols that need documentation as TODOs
Mike Becker <universe@uap-core.de>
parents:
1141
diff
changeset
|
27 | |
9437530176bc
add symbols that need documentation as TODOs
Mike Becker <universe@uap-core.de>
parents:
1141
diff
changeset
|
28 | ## Undocumented Symbols (TODO) |
9437530176bc
add symbols that need documentation as TODOs
Mike Becker <universe@uap-core.de>
parents:
1141
diff
changeset
|
29 | ### cx_empty_map |
9437530176bc
add symbols that need documentation as TODOs
Mike Becker <universe@uap-core.de>
parents:
1141
diff
changeset
|
30 | ### cxEmptyMap |
9437530176bc
add symbols that need documentation as TODOs
Mike Becker <universe@uap-core.de>
parents:
1141
diff
changeset
|
31 | ### cxMapFree |
9437530176bc
add symbols that need documentation as TODOs
Mike Becker <universe@uap-core.de>
parents:
1141
diff
changeset
|
32 | ### cxMapMutIterator |
9437530176bc
add symbols that need documentation as TODOs
Mike Becker <universe@uap-core.de>
parents:
1141
diff
changeset
|
33 | ### cxMapMutIteratorKeys |
9437530176bc
add symbols that need documentation as TODOs
Mike Becker <universe@uap-core.de>
parents:
1141
diff
changeset
|
34 | ### cxMapMutIteratorValues |