Skip to content

Commit

Permalink
Update map api
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrikwidlund committed Jan 19, 2017
1 parent 33b3b82 commit 623160f
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions docs/apireference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,11 @@ For performance reasons some support callbacks need to be included in various ca
The *equal* callback is called with a pointer to two elements, *element1* and *element2*, and should return 1 if
the elements are equal.

.. type:: void (*set)(void *destination, void *source)

The *set* callback is called with a pointer to a *source* element from where the element data is read, and a
*destination* element where the data is written.

.. type:: void (*release)(void *element)

The *release* callback is called with a pointer a map element when it is removed from the map.
Expand All @@ -322,7 +327,7 @@ For performance reasons some support callbacks need to be included in various ca

This data structure represents the map object.

.. function:: void map_construct(map *map, size_t element_size, void *element_empty)
.. function:: void map_construct(map *map, size_t element_size, void *element_empty, int (*set)(void *, void *))

Constructs an empty *map*, where each element containing the key and value is of the size *element_size*, and
*element_empty* corresponds to an empty element.
Expand All @@ -335,7 +340,7 @@ For performance reasons some support callbacks need to be included in various ca

Returns the number of elements in the *map*.

.. function:: void map_reserve(map *map, size_t size, size_t (*hash)(void *), int (*equal)(void *, void *))
.. function:: void map_reserve(map *map, size_t size, size_t (*hash)(void *), int (*equal)(void *, void *), int (*set)(void *, void *))

Reserves space in the *map* for *size* number of elements.

Expand All @@ -348,15 +353,15 @@ For performance reasons some support callbacks need to be included in various ca
Returns a pointer to the element in the *map* that has a key that corrensponds to the key in *element*. If
the key is not found a pointer to an empty element is returned.

.. function:: void map_insert(map *map, void *element, size_t (*hash)(void *), int (*equal)(void *, void *), void (*release)(void *))
.. function:: void map_insert(map *map, void *element, size_t (*hash)(void *), int (*equal)(void *, void *), int (*set)(void *, void *), void (*release)(void *))

Insert an *element* into the *map*. If the key of the element already exists in the map the element will be released.

.. function:: void map_erase(map *map, void *element, size_t (*hash)(void *), int (*equal)(void *, void *), void (*release)(void *))
.. function:: void map_erase(map *map, void *element, size_t (*hash)(void *), int (*equal)(void *, void *), int (*set)(void *, void *), void (*release)(void *))

Removes an *element* from the *map*.

.. function:: void map_clear(map *map, int (*equal)(void *, void *), void (*release)(void *))
.. function:: void map_clear(map *map, int (*equal)(void *, void *), int (*)(void *set, void *), void (*release)(void *))

Clears the *map* of all the elements.

Expand Down

0 comments on commit 623160f

Please sign in to comment.