docs/src/modules.md

changeset 280
6e3c4036a80c
parent 279
ee37b179e597
child 281
e8146a561e73
equal deleted inserted replaced
279:ee37b179e597 280:6e3c4036a80c
13 via `#include <ucx/MODULENAME.h>`. 13 via `#include <ucx/MODULENAME.h>`.
14 Required modules are included automatically. 14 Required modules are included automatically.
15 15
16 <div id="modules" align="center"> 16 <div id="modules" align="center">
17 17
18 ----------------------- ---------------------- ---------------------------- ------------------------- 18 ----------------------- ---------------------- ---------------------------- -------------------------
19 [Allocator](#allocator) [AVL&nbsp;Tree](#avl) [Buffer](#buffer) [List](#list) 19 [Allocator](#allocator) [AVL&nbsp;Tree](#avl-tree) [Buffer](#buffer) [List](#list)
20 [Logging](#logging) [Map](#map) [Memory&nbsp;Pool](#mempool) [Properties](#properties) 20 [Logging](#logging) [Map](#map) [Memory&nbsp;Pool](#memory-pool) [Properties](#properties)
21 [Stack](#stack) [String](#string) [Testing](#test) [Utilities](#utils) 21 [Stack](#stack) [String](#string) [Testing](#testing) [Utilities](#utilities)
22 ----------------------- ---------------------- ---------------------------- ------------------------- 22 ----------------------- ---------------------- ---------------------------- -------------------------
23 23
24 </div> 24 </div>
25
26 <a name="allocator"></a>
27 25
28 ## Allocator 26 ## Allocator
29 27
30 *Header file:* [allocator.h](api/allocator_8h.html) 28 *Header file:* [allocator.h](api/allocator_8h.html)
31 *Required modules:* None. 29 *Required modules:* None.
39 of the respective libc function but each of them takes the pointer to the 37 of the respective libc function but each of them takes the pointer to the
40 memory area / pool as first argument. 38 memory area / pool as first argument.
41 39
42 As the pointer to the memory area / pool can be arbitrarily chosen, any data 40 As the pointer to the memory area / pool can be arbitrarily chosen, any data
43 can be provided to the memory management functions. One example is the 41 can be provided to the memory management functions. One example is the
44 [UCX Memory Pool](#mempool). 42 [UCX Memory Pool](#memory-pool).
45
46 <a name="avl"></a>
47 43
48 ## AVL Tree 44 ## AVL Tree
49 45
50 *Header file:* [avl.h](api/avl_8h.html) 46 *Header file:* [avl.h](api/avl_8h.html)
51 *Required modules:* [Allocator](#allocator) 47 *Required modules:* [Allocator](#allocator)
53 This binary search tree implementation allows average O(1) insertion and 49 This binary search tree implementation allows average O(1) insertion and
54 removal of elements (excluding binary search time). 50 removal of elements (excluding binary search time).
55 All common binary tree operations are implemented. Furthermore, this module 51 All common binary tree operations are implemented. Furthermore, this module
56 provides search functions via lower and upper bounds. 52 provides search functions via lower and upper bounds.
57 53
58 <a name="buffer"></a>
59
60 ## Buffer 54 ## Buffer
61 55
62 *Header file:* [buffer.h](api/buffer_8h.html) 56 *Header file:* [buffer.h](api/buffer_8h.html)
63 *Required modules:* None. 57 *Required modules:* None.
64 58
65 Instances of this buffer implementation can be used to read from or to write to 59 Instances of this buffer implementation can be used to read from or to write to
66 memory like you would do with a stream. This allows the use of 60 memory like you would do with a stream. This allows the use of
67 `ucx_stream_copy` from the [Utilities](#utils) module to copy contents from one 61 `ucx_stream_copy` from the [Utilities](#utilities) module to copy contents from one
68 buffer to another or from file or network streams to the buffer and 62 buffer to another or from file or network streams to the buffer and
69 vice-versa. 63 vice-versa.
70 64
71 More features for convenient use of the buffer can be enabled, like automatic 65 More features for convenient use of the buffer can be enabled, like automatic
72 memory management and automatic resizing of the buffer space. 66 memory management and automatic resizing of the buffer space.
73 See the documentation of the macro constants in the header file for more 67 See the documentation of the macro constants in the header file for more
74 information. 68 information.
75 69
76 <a name="list"></a>
77
78 ## List 70 ## List
79 71
80 *Header file:* [list.h](api/list_8h.html) 72 *Header file:* [list.h](api/list_8h.html)
81 *Required modules:* [Allocator](#allocator) 73 *Required modules:* [Allocator](#allocator)
82 74
83 This module provides the data structure and several functions for a doubly 75 This module provides the data structure and several functions for a doubly
84 linked list. Among the common operations like insert, remove, search and sort, 76 linked list. Among the common operations like insert, remove, search and sort,
85 we allow convenient iteration via a special `UCX_FOREACH` macro. 77 we allow convenient iteration via a special `UCX_FOREACH` macro.
86 78
87 <a name="logging"></a>
88
89 ## Logging 79 ## Logging
90 80
91 *Header file:* [logging.h](api/logging_8h.html) 81 *Header file:* [logging.h](api/logging_8h.html)
92 *Required modules:* [Map](#map), [String](#string) 82 *Required modules:* [Map](#map), [String](#string)
93 83
94 The logging module comes with some predefined log levels and allows some more 84 The logging module comes with some predefined log levels and allows some more
95 customization. You may choose if you want to get timestamps or source file and 85 customization. You may choose if you want to get timestamps or source file and
96 line number logged automatically when outputting a message. 86 line number logged automatically when outputting a message.
97 87
98 88
99 <a name="map"></a>
100
101 ## Map 89 ## Map
102 90
103 *Header file:* [map.h](api/map_8h.html) 91 *Header file:* [map.h](api/map_8h.html)
104 *Required modules:* [Allocator](#allocator), [String](#string) 92 *Required modules:* [Allocator](#allocator), [String](#string)
105 93
106 This module provides a hash map implementation using murmur hash 2 and separate 94 This module provides a hash map implementation using murmur hash 2 and separate
107 chaining with linked lists. Similarly to the list module, we provide a 95 chaining with linked lists. Similarly to the list module, we provide a
108 `UCX_MAP_FOREACH` macro to conveniently iterate through the key/value pairs. 96 `UCX_MAP_FOREACH` macro to conveniently iterate through the key/value pairs.
109
110 <a name="mempool"></a>
111 97
112 ## Memory Pool 98 ## Memory Pool
113 99
114 *Header file:* [mempool.h](api/mempool_8h.html) 100 *Header file:* [mempool.h](api/mempool_8h.html)
115 *Required modules:* [Allocator](#allocator) 101 *Required modules:* [Allocator](#allocator)
118 This pool allows you to register destructor functions for the allocated memory, 104 This pool allows you to register destructor functions for the allocated memory,
119 which are automatically called on the destruction of the pool. 105 which are automatically called on the destruction of the pool.
120 But you may also register *independent* destructor functions within a pool in 106 But you may also register *independent* destructor functions within a pool in
121 case, some external library allocated memory for you, which you wish to be 107 case, some external library allocated memory for you, which you wish to be
122 destroyed together with this pool. 108 destroyed together with this pool.
123
124 <a name="properties"></a>
125 109
126 ## Properties 110 ## Properties
127 111
128 *Header file:* [properties.h](api/properties_8h.html) 112 *Header file:* [properties.h](api/properties_8h.html)
129 *Required modules:* [Map](#map) 113 *Required modules:* [Map](#map)
160 // Don't forget to free the values before freeing the map 144 // Don't forget to free the values before freeing the map
161 ucx_map_free_content(myprops, NULL); 145 ucx_map_free_content(myprops, NULL);
162 ucx_map_free(myprops); 146 ucx_map_free(myprops);
163 fclose(file); 147 fclose(file);
164 ``` 148 ```
165
166 <a name="stack"></a>
167
168 ## Stack 149 ## Stack
169 150
170 *Header file:* [stack.h](api/stack_8h.html) 151 *Header file:* [stack.h](api/stack_8h.html)
171 *Required modules:* [Allocator](#allocator) 152 *Required modules:* [Allocator](#allocator)
172 153
176 allocator. You may still choose if you want to use stack or heap memory 157 allocator. You may still choose if you want to use stack or heap memory
177 for the underlying space. 158 for the underlying space.
178 159
179 A typical use case is an algorithm where you need to allocate and free large 160 A typical use case is an algorithm where you need to allocate and free large
180 amounts of memory very frequently. 161 amounts of memory very frequently.
181
182 <a name="string"></a>
183 162
184 ## String 163 ## String
185 164
186 *Header file:* [string.h](api/string_8h.html) 165 *Header file:* [string.h](api/string_8h.html)
187 *Required modules:* [Allocator](#allocator) 166 *Required modules:* [Allocator](#allocator)
262 some 241 some
263 strings 242 strings
264 243
265 The memory pool ensures, that all strings are freed. 244 The memory pool ensures, that all strings are freed.
266 245
267 <a name="test"></a>
268
269 ## Testing 246 ## Testing
270 247
271 *Header file:* [test.h](api/test_8h.html) 248 *Header file:* [test.h](api/test_8h.html)
272 *Required modules:* None. 249 *Required modules:* None.
273 250
274 This module provides a testing framework which allows you to execute test cases 251 This module provides a testing framework which allows you to execute test cases
275 within test suites. 252 within test suites.
276 To avoid code duplication within tests, we also provide the possibility to 253 To avoid code duplication within tests, we also provide the possibility to
277 define test subroutines. 254 define test subroutines.
278
279 <a name="utils"></a>
280 255
281 ## Utilities 256 ## Utilities
282 257
283 *Header file:* [utils.h](api/utils_8h.html) 258 *Header file:* [utils.h](api/utils_8h.html)
284 *Required modules:* [Allocator](#allocator), [String](#string) 259 *Required modules:* [Allocator](#allocator), [String](#string)

mercurial