docs/Writerside/topics/map.h.md

changeset 1587
7156d6699410
parent 1579
0393c67556ec
equal deleted inserted replaced
1586:7f1cadc3ebc1 1587:7156d6699410
467 ``` 467 ```
468 468
469 The required behavior for the implementations is described in the following table. 469 The required behavior for the implementations is described in the following table.
470 You can always look at the source code of the UCX hash map to get inspiration. 470 You can always look at the source code of the UCX hash map to get inspiration.
471 471
472 | Function | Description | 472 | Function | Description |
473 |--------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| 473 |--------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
474 | `clear` | Invoke [destructor functions](collection.h.md#destructor-functions) on all elements and remove them from the map. | 474 | `clear` | Invoke [destructor functions](collection.h.md#destructor-functions) on all elements and remove them from the map. |
475 | `deallocate` | Invoke destructor functions on all elements and deallocate the entire map memory. | 475 | `deallocate` | Invoke destructor functions on all elements and deallocate the entire map memory. |
476 | `put` | Store an element in the map. If an element is already stored, invoke the destructor functions on that element and replace it with the new element. When the value pointer is `NULL`, only allocate memory without copying an existing value. Return a pointer to the allocated memory, or `NULL` when allocation fails. | 476 | `put` | Store an element in the map. If an element is already stored, invoke the destructor functions on that element and replace it with the new element. When the value pointer is `NULL`, only allocate memory without copying an existing value. Return `CxMapEntry` where the `key` is `NULL` when allocation fails. |
477 | `get` | Look up the specified key and return the associated value (or `NULL` if the key was not found). | 477 | `get` | Look up the specified key and return the associated value (or `NULL` if the key was not found). |
478 | `remove` | Remove an element from the map. If a target buffer is specified, copy the elements to that buffer. Otherwise, invoke the destructor functions for the element. If the key was not found in the map, return non-zero. | 478 | `remove` | Remove an element from the map. If a target buffer is specified, copy the elements to that buffer. Otherwise, invoke the destructor functions for the element. If the key was not found in the map, return non-zero. |
479 | `iterator` | Return an iterator over the pairs, the keys, or the values, depending on the iterator type passed with the last argument. | 479 | `iterator` | Return an iterator over the pairs, the keys, or the values, depending on the iterator type passed with the last argument. |
480 480
481 > In contrast to the list interface, there is no `cx_map_init()` function which automatically 481 > In contrast to the list interface, there is no `cx_map_init()` function which automatically
482 > configures a wrapping mechanism when `CX_STORE_POINTERS` is used. 482 > configures a wrapping mechanism when `CX_STORE_POINTERS` is used.
483 > That means, in the implementation of the above functions you must take care of distinguishing between 483 > That means, in the implementation of the above functions you must take care of distinguishing between
484 > maps that are storing pointers and that are storing elements yourself (if you want to support both). 484 > maps that are storing pointers and that are storing elements yourself (if you want to support both).

mercurial