docs/src/modules.md

Mon, 13 Nov 2017 12:21:55 +0100

author
Mike Becker <universe@uap-core.de>
date
Mon, 13 Nov 2017 12:21:55 +0100
changeset 264
24f5484bae97
parent 259
2f5dea574a75
child 267
f4789572c9d6
permissions
-rw-r--r--

web doc has now proper titles

     1 ---
     2 title: Modules
     3 ---
     5 UCX provides several modules for data structures and algorithms.
     6 You may choose to use specific modules by inclueding the corresponding header
     7 file.
     8 Please note, that some modules make use of other UCX modules.
     9 For instance, the [Allocator](#allocator) module is used by many other modules
    10 to allow flexible memory allocation.
    11 By default the header files are placed into an `ucx` directory within your
    12 systems include directory. In this case you can use an module by including it
    13 via `#include <ucx/MODULENAME.h>`.
    14 Required modules are included automatically.
    16 <a name="allocator"></a>
    18 ## Allocator
    20 *Header file:* [allocator.h](api/allocator_8h.html)  
    21 *Required modules:* None.
    23 A UCX allocator consists of a pointer to the memory area / pool and four
    24 function pointers to memory management functions operating on this memory
    25 area / pool. These functions shall behave equivalent to the standard libc
    26 functions `malloc`, `calloc`, `realloc` and `free`.
    28 The signature of the memory management functions is based on the signature
    29 of the respective libc function but each of them takes the pointer to the
    30 memory area / pool as first argument.
    32 As the pointer to the memory area / pool can be arbitrarily chosen, any data
    33 can be provided to the memory management functions. One example is the
    34 [UCX Memory Pool](#mempool).
    36 <a name="avl"></a>
    38 ## AVL Tree
    40 *Header file:* [avl.h](api/avl_8h.html)  
    41 *Required modules:* [Allocator](#allocator)
    43 This binary search tree implementation allows average O(1) insertion and
    44 removal of elements (excluding binary search time).
    45 All common binary tree operations are implemented. Furthermore, this module
    46 provides search functions via lower and upper bounds.
    48 <a name="buffer"></a>
    50 ## Buffer
    52 *Header file:* [buffer.h](api/buffer_8h.html)  
    53 *Required modules:* None.
    55 Instances of this buffer implementation can be used to read from or to write to
    56 memory like you would do with a stream. This allows the use of
    57 `ucx_stream_copy` from the [Utilities](#utils) module to copy contents from one
    58 buffer to another or from file or network streams to the buffer and
    59 vice-versa.
    61 More features for convenient use of the buffer can be enabled, like automatic
    62 memory management and automatic resizing of the buffer space.
    63 See the documentation of the macro constants in the header file for more
    64 information.
    66 <a name="list"></a>
    68 ## List
    70 *Header file:* [list.h](api/list_8h.html)  
    71 *Required modules:* [Allocator](#allocator)
    73 This module provides the data structure and several functions for a doubly
    74 linked list. Among the common operations like insert, remove, search and sort,
    75 we allow convenient iteration via a special `UCX_FOREACH` macro.
    77 <a name="logging"></a>
    79 ## Logging
    81 *Header file:* [logging.h](api/logging_8h.html)  
    82 *Required modules:* [Map](#map), [String](#string)
    84 The logging module comes with some predefined log levels and allows some more
    85 customization. You may choose if you want to get timestamps or source file and
    86 line number logged automatically when outputting a message.
    89 <a name="map"></a>
    91 ## Map
    93 *Header file:* [map.h](api/map_8h.html)  
    94 *Required modules:* [Allocator](#allocator), [String](#string)
    96 This module provides a hash map implementation using murmur hash 2 and separate
    97 chaining with linked lists. Similarly to the list module, we provide a
    98 `UCX_MAP_FOREACH` macro to conveniently iterate through the key/value pairs.
   100 <a name="mempool"></a>
   102 ## Memory Pool
   104 *Header file:* [mempool.h](api/mempool_8h.html)  
   105 *Required modules:* [Allocator](#allocator)
   107 Here we have a concrete allocator implementation in the sense of a memory pool.
   108 This pool allows you to register destructor functions for the allocated memory,
   109 which are automatically called on the destruction of the pool.
   110 But you may also register *independent* destructor functions within a pool in
   111 case, some external library allocated memory for you, which you wish to be
   112 destroyed together with this pool.
   114 <a name="properties"></a>
   116 ## Properties
   118 *Header file:* [properties.h](api/properties_8h.html)  
   119 *Required modules:* [Map](#map)
   121 This module provides load and store function for `*.properties` files.
   122 The key/value pairs are stored within an UCX Map.
   124 <a name="stack"></a>
   126 ## Stack
   128 *Header file:* [stack.h](api/stack_8h.html)  
   129 *Required modules:* [Allocator](#allocator)
   131 This concrete implementation of an UCX Allocator allows you to grab some amount
   132 of memory which is then handled as a stack.
   133 Please note, that the term *stack* only refers to the behavior of this
   134 allocator. You may still choose if you want to use stack or heap memory
   135 for the underlying space.
   137 A typical use case is an algorithm where you need to allocate and free large
   138 amounts of memory very frequently.
   140 <a name="string"></a>
   142 ## String
   144 *Header file:* [string.h](api/string_8h.html)  
   145 *Required modules:* [Allocator](#allocator)
   147 This module provides a safe implementation of bounded string.
   148 Usually C strings do not carry a length. While for zero-terminated strings you
   149 can easily get the length with `strlen`, this is not generally possible for
   150 arbitrary strings.
   151 The `sstr_t` type of this module always carries the string and its length to
   152 reduce the risk of buffer overflows dramatically.
   154 <a name="test"></a>
   156 ## Testing
   158 *Header file:* [test.h](api/test_8h.html)  
   159 *Required modules:* None.
   161 This module provides a testing framework which allows you to execute test cases
   162 within test suites.
   163 To avoid code duplication within tests, we also provide the possibility to
   164 define test subroutines.
   166 <a name="utils"></a>
   168 ## Utilities
   170 *Header file:* [utils.h](api/utils_8h.html)  
   171 *Required modules:* [Allocator](#allocator), [String](#string)
   173 In this module we provide very general utility function for copy and compare
   174 operations.
   175 We also provide several `printf` variants to conveniently print formatted data
   176 to streams or strings.

mercurial