Throughout the documentation, the following prefixes will be used:
Global_
The library prefix: for applications, this is typically
empty, for an xyz-Library, this is either XYZ_, xyz_ or
Xyz, depending on the identifier in occurs in.
Template
Instantiation
Global_MAP_OK
XYZ_MAP_OK
Global_map_new
xyz_map_new
Map_
This is equivalent to Global_map_iType_oType, or the name
that was set with -name=... for this data structure.
The case and underbar convention is adjusted, too.
Assuming a library prefix xyz and iType=int *,
oType == int, you get:
In the following, for many functions, the error code values are given. There are
two kinds, those for success and those for failure. The error codes (if set at all)
are always stored in the global variable Global_map_errno, no mattern whether the function
returns its success or not. Note that the error value MAP_ERR_ASSERTIONFAILED
is never explicitly given, because it
can happen virtually always
is considered a fatal error and should therefore lead to program
abortion immediately.
Successful operation is indicated by Global_MAP_OK, Global_MAP_WARN_*, and
Global_MAP_REHASH*.
Failure is indicated by Global_MAP_ERR_*. If a functions does not return the error code,
its result value in case of an error is always the zero element of the result type.
I.e. NULL for pointers, 0 for integers, the user specified zero element for iType or oType,
Global_ERWIN_FALSE for Global_ERWIN_BOOL, etc.
Functions that only set map_errno to Global_MAP_REHASH_* or Global_MAP_OK will return
void if they do not have a natural result.
Note
The term `success' means that the function could perform its operation
according to the specification. E.g. if you call _insert and the
key exists, the functions does not insert it. However, this is no
error. It is defined that it should not be inserted in this case.
Accordingly, you get a warning, not an error.
Quite private: do not use unless you know what you're doing:
Needed if you want to use maps without a pointer in vectors. vectors use
C-style memory allocation because they need realloc. The constructor/destructors
are invoked via these two functions.
Returns a pointer to the found element or one to a newly allocated one.
In the case when it was not possible to allocate space for a new element,
the result NULL. Otherwise, it is not NULL.
If a new element was introduced, errno will be set to MAP_WARN_KEYNOTFOUND,
otherwise to MAP_OK. Note again that in both cases, the result is non-NULL!
Note
If oType == oTypeVar, you may not use the pointer to directly
write into the hash table because this circumvents copying and that
is prohibited. Use poke_no_ocopy for things like that to make it
explicit.
Error Codes (Global_map_errno)
In case of operation, Global_MAP_OK is signalled.
Global_MAP_WARN_KEYNOTFOUND
Note that a warning means that the operation was successfully completed.
Returns the found element or introduces an empty element into the
map and returns that (use Map_ENSURE_VALUE to determine the value
that is introduced).
Also consider find_ptr_ensure if you want to modify the (newly
introduced) value. Also see Map_ensure if you need the key, not
the value after the operation.
Error Codes (Global_map_errno)
In case of operation, Global_MAP_OK is signalled.
Global_MAP_WARN_KEYNOTFOUND
Note that a warning means that the operation was successfully completed.
Returns a pointer to the found element or NULL on failure.
Note
If oType == oTypeVar, you may not use the pointer to directly
write into the hash table because this circumvents copying and that
is prohibited. Use poke_no_ocopy for things like that to make it
explicit.
Error Codes (Global_map_errno)
In case of operation, Global_MAP_OK is signalled.
Global_MAP_WARN_KEYNOTFOUND
Note that a warning means that the operation was successfully completed.
Returns a pointer to the found element or one to a newly allocated one.
In the case when it was not possible to allocate space for a new element,
the result NULL. Otherwise, it is not NULL.
If a new element was introduced, errno will be set to MAP_WARN_KEYNOTFOUND,
otherwise to MAP_OK. Note again that in both cases, the result is non-NULL!
Note
If oType == oTypeVar, you may not use the pointer to directly
write into the hash table because this circumvents copying and that
is prohibited. Use poke_no_ocopy for things like that to make it
explicit.
Error Codes (Global_map_errno)
In case of operation, Global_MAP_OK is signalled.
Global_MAP_WARN_KEYNOTFOUND
Note that a warning means that the operation was successfully completed.
Returns a pointer to the found element or NULL on failure.
Note
If oType == oTypeVar, you may not use the pointer to directly
write into the hash table because this circumvents copying and that
is prohibited. Use poke_no_ocopy for things like that to make it
explicit.
Error Codes (Global_map_errno)
In case of operation, Global_MAP_OK is signalled.
Global_MAP_WARN_KEYNOTFOUND
Note that a warning means that the operation was successfully completed.
Returns a pointer to the found element or one to a newly allocated one.
In the case when it was not possible to allocate space for a new element,
the result NULL. Otherwise, it is not NULL.
If a new element was introduced, errno will be set to MAP_WARN_KEYNOTFOUND,
otherwise to MAP_OK. Note again that in both cases, the result is non-NULL!
Note
If oType == oTypeVar, you may not use the pointer to directly
write into the hash table because this circumvents copying and that
is prohibited. Use poke_no_ocopy for things like that to make it
explicit.
Error Codes (Global_map_errno)
In case of operation, Global_MAP_OK is signalled.
Global_MAP_WARN_KEYNOTFOUND
Note that a warning means that the operation was successfully completed.
Returns the found element or introduces an empty element into the
map and returns that (use Map_ENSURE_VALUE to determine the value
that is introduced).
Also consider find_ptr_ensure if you want to modify the (newly
introduced) value. Also see Map_ensure if you need the key, not
the value after the operation.
Error Codes (Global_map_errno)
In case of operation, Global_MAP_OK is signalled.
Global_MAP_WARN_KEYNOTFOUND
Note that a warning means that the operation was successfully completed.
Returns the found element or the zero element if not found.
For maps with 0 or 1 elements and in the non-deterministic
case, this is very fast. In the deterministic mode, this
is O(n). In weak determinism, it is typically O(1) as in
the non-deterministic mode. (The very unlikely worst case
is always O(n)).
Error Codes (Global_map_errno)
In case of operation, Global_MAP_OK is signalled.
Global_MAP_WARN_KEYNOTFOUND
Note that a warning means that the operation was successfully completed.
Returns a pointer to some element or NULL on failure.
Note
If oType == oTypeVar, you may not use the pointer to directly
write into the hash table because this circumvents copying and that
is prohibited. Use poke_no_ocopy for things like that to make it
explicit.
Error Codes (Global_map_errno)
In case of operation, Global_MAP_OK is signalled.
Global_MAP_WARN_KEYNOTFOUND
Note that a warning means that the operation was successfully completed.
int Map_insert_map (Map_t * self, Map_t const * other)
Inserts all keys from other into self. If any key is not inserted,
returns WARN_EXISTINGKEY.
Error Codes (Global_map_errno)
In case of operation, Global_MAP_OK is signalled.
Global_MAP_WARN_EXISTINGKEY
Global_MAP_REHASH_*
If memory is exhausted, Global_MAP_ERR_NOMEM is signalled.
If the option Map_NOMEM_IS_FATAL is 1, this error cannot happen: instead, the program is immediately terminated.
Note that a warning means that the operation was successfully completed.
Note that a rehash warning means that the operation was successfully completed. However, there may be serious problems like heap corruption, so handling this as an error is not a bad idea.
int Map_insert_map (Map_t * self, Map_t const * other)
Inserts all keys from other into self. If any key is not inserted,
returns WARN_EXISTINGKEY.
Error Codes (Global_map_errno)
In case of operation, Global_MAP_OK is signalled.
Global_MAP_WARN_EXISTINGKEY
Global_MAP_REHASH_*
If memory is exhausted, Global_MAP_ERR_NOMEM is signalled.
If the option Map_NOMEM_IS_FATAL is 1, this error cannot happen: instead, the program is immediately terminated.
Note that a warning means that the operation was successfully completed.
Note that a rehash warning means that the operation was successfully completed. However, there may be serious problems like heap corruption, so handling this as an error is not a bad idea.
int Map_insert_map (Map_t * self, Map_t const * other)
Inserts all keys from other into self. If any key is not inserted,
returns WARN_EXISTINGKEY.
Error Codes (Global_map_errno)
In case of operation, Global_MAP_OK is signalled.
Global_MAP_WARN_EXISTINGKEY
Global_MAP_REHASH_*
If memory is exhausted, Global_MAP_ERR_NOMEM is signalled.
If the option Map_NOMEM_IS_FATAL is 1, this error cannot happen: instead, the program is immediately terminated.
Note that a warning means that the operation was successfully completed.
Note that a rehash warning means that the operation was successfully completed. However, there may be serious problems like heap corruption, so handling this as an error is not a bad idea.
int Map_insert_map (Map_t * self, Map_t const * other)
Inserts all keys from other into self. If any key is not inserted,
returns WARN_EXISTINGKEY.
Error Codes (Global_map_errno)
In case of operation, Global_MAP_OK is signalled.
Global_MAP_WARN_EXISTINGKEY
Global_MAP_REHASH_*
If memory is exhausted, Global_MAP_ERR_NOMEM is signalled.
If the option Map_NOMEM_IS_FATAL is 1, this error cannot happen: instead, the program is immediately terminated.
Note that a warning means that the operation was successfully completed.
Note that a rehash warning means that the operation was successfully completed. However, there may be serious problems like heap corruption, so handling this as an error is not a bad idea.
Change an existing value for the given index (errno=OK). If the index does
not exist, do not modify the map nothing (errno=WARN_KETNOTFOUND).
Returns the old value or Global_oType_ZERO if it is new in which case the map is
not changed. Nothing is freed, value is copied.
Error Codes (Global_map_errno)
In case of operation, Global_MAP_OK is signalled.
Global_MAP_WARN_KEYNOTFOUND
Global_MAP_REHASH_*
If memory is exhausted, Global_MAP_ERR_NOMEM is signalled.
If the option Map_NOMEM_IS_FATAL is 1, this error cannot happen: instead, the program is immediately terminated.
Note that a warning means that the operation was successfully completed.
Note that a rehash warning means that the operation was successfully completed. However, there may be serious problems like heap corruption, so handling this as an error is not a bad idea.
int Map_modify_map (Map_t * self, Map_t const * other)
like Map_modify on all entries in other. If any key was not found,
WARN_KEYNOTFOUND is returned.
Error Codes (Global_map_errno)
In case of operation, Global_MAP_OK is signalled.
Global_MAP_WARN_KEYNOTFOUND
Global_MAP_REHASH_*
If memory is exhausted, Global_MAP_ERR_NOMEM is signalled.
If the option Map_NOMEM_IS_FATAL is 1, this error cannot happen: instead, the program is immediately terminated.
Note that a warning means that the operation was successfully completed.
Note that a rehash warning means that the operation was successfully completed. However, there may be serious problems like heap corruption, so handling this as an error is not a bad idea.
int Map_modify_map (Map_t * self, Map_t const * other)
like Map_modify on all entries in other. If any key was not found,
WARN_KEYNOTFOUND is returned.
Error Codes (Global_map_errno)
In case of operation, Global_MAP_OK is signalled.
Global_MAP_WARN_KEYNOTFOUND
Global_MAP_REHASH_*
If memory is exhausted, Global_MAP_ERR_NOMEM is signalled.
If the option Map_NOMEM_IS_FATAL is 1, this error cannot happen: instead, the program is immediately terminated.
Note that a warning means that the operation was successfully completed.
Note that a rehash warning means that the operation was successfully completed. However, there may be serious problems like heap corruption, so handling this as an error is not a bad idea.
int Map_modify_map (Map_t * self, Map_t const * other)
like Map_modify on all entries in other. If any key was not found,
WARN_KEYNOTFOUND is returned.
Error Codes (Global_map_errno)
In case of operation, Global_MAP_OK is signalled.
Global_MAP_WARN_KEYNOTFOUND
Global_MAP_REHASH_*
If memory is exhausted, Global_MAP_ERR_NOMEM is signalled.
If the option Map_NOMEM_IS_FATAL is 1, this error cannot happen: instead, the program is immediately terminated.
Note that a warning means that the operation was successfully completed.
Note that a rehash warning means that the operation was successfully completed. However, there may be serious problems like heap corruption, so handling this as an error is not a bad idea.
int Map_modify_map (Map_t * self, Map_t const * other)
like Map_modify on all entries in other. If any key was not found,
WARN_KEYNOTFOUND is returned.
Error Codes (Global_map_errno)
In case of operation, Global_MAP_OK is signalled.
Global_MAP_WARN_KEYNOTFOUND
Global_MAP_REHASH_*
If memory is exhausted, Global_MAP_ERR_NOMEM is signalled.
If the option Map_NOMEM_IS_FATAL is 1, this error cannot happen: instead, the program is immediately terminated.
Note that a warning means that the operation was successfully completed.
Note that a rehash warning means that the operation was successfully completed. However, there may be serious problems like heap corruption, so handling this as an error is not a bad idea.
Insert or modify a value: introduce value for given index if it does not
exist (errno=OK) or change value if index does exist (errno=WARN_EXISTINGKEY).
Similar to Map_modify, but value is freed and the status instead of the value
is returned. Furthermore, of course, it is different in that if the value
does not exist, it will be inserted.
If memory is exhausted, Global_MAP_ERR_NOMEM is signalled.
If the option Map_NOMEM_IS_FATAL is 1, this error cannot happen: instead, the program is immediately terminated.
Note that a warning means that the operation was successfully completed.
Note that a rehash warning means that the operation was successfully completed. However, there may be serious problems like heap corruption, so handling this as an error is not a bad idea.
If memory is exhausted, Global_MAP_ERR_NOMEM is signalled.
If the option Map_NOMEM_IS_FATAL is 1, this error cannot happen: instead, the program is immediately terminated.
Note that a rehash warning means that the operation was successfully completed. However, there may be serious problems like heap corruption, so handling this as an error is not a bad idea.
If memory is exhausted, Global_MAP_ERR_NOMEM is signalled.
If the option Map_NOMEM_IS_FATAL is 1, this error cannot happen: instead, the program is immediately terminated.
Note that a rehash warning means that the operation was successfully completed. However, there may be serious problems like heap corruption, so handling this as an error is not a bad idea.
If memory is exhausted, Global_MAP_ERR_NOMEM is signalled.
If the option Map_NOMEM_IS_FATAL is 1, this error cannot happen: instead, the program is immediately terminated.
Note that a rehash warning means that the operation was successfully completed. However, there may be serious problems like heap corruption, so handling this as an error is not a bad idea.
If memory is exhausted, Global_MAP_ERR_NOMEM is signalled.
If the option Map_NOMEM_IS_FATAL is 1, this error cannot happen: instead, the program is immediately terminated.
Note that a rehash warning means that the operation was successfully completed. However, there may be serious problems like heap corruption, so handling this as an error is not a bad idea.
Returns the old value or Global_oType_ZERO. Does not free the value (which is
returned), but only the key. A more appropriate name for this function
might be `steal', because the value is kept.
In error-free operation, returns errno=OK if the index was found and erased,
and WARN_KEYNOTFOUND if the index was not found.
Error Codes (Global_map_errno)
In case of operation, Global_MAP_OK is signalled.
Global_MAP_WARN_KEYNOTFOUND
Global_MAP_REHASH_*
Note that a warning means that the operation was successfully completed.
Note that a rehash warning means that the operation was successfully completed. However, there may be serious problems like heap corruption, so handling this as an error is not a bad idea.
int Map_remove_map (Map_t * self, Map_t const * other)
like Map_remove on all entries in other. If any key was not found,
WARN_KEYNOTFOUND is returned.
Error Codes (Global_map_errno)
In case of operation, Global_MAP_OK is signalled.
Global_MAP_WARN_KEYNOTFOUND
Global_MAP_REHASH_*
Note that a warning means that the operation was successfully completed.
Note that a rehash warning means that the operation was successfully completed. However, there may be serious problems like heap corruption, so handling this as an error is not a bad idea.
int Map_remove_map (Map_t * self, Map_t const * other)
like Map_remove on all entries in other. If any key was not found,
WARN_KEYNOTFOUND is returned.
Error Codes (Global_map_errno)
In case of operation, Global_MAP_OK is signalled.
Global_MAP_WARN_KEYNOTFOUND
Global_MAP_REHASH_*
Note that a warning means that the operation was successfully completed.
Note that a rehash warning means that the operation was successfully completed. However, there may be serious problems like heap corruption, so handling this as an error is not a bad idea.
int Map_remove_if (Map_t * self, Map_feature_t feature, Global_ERWIN_BOOL value)
Remove some entries from the map according to a given feature. This
is much faster than repeated deletions and maximally requires one
rehash operation only.
Note
Even if the library is compiled with determinism, the order of the
invocations of the feature callback is non-deterministic!
Same as Map_remove, but value is freed. In error-free operation, returns
errno=OK if the index was found and erased, and WARN_KEYNOTFOUND if the
index was not found.
Error Codes (Global_map_errno)
In case of operation, Global_MAP_OK is signalled.
Global_MAP_WARN_KEYNOTFOUND
Global_MAP_REHASH_*
Note that a warning means that the operation was successfully completed.
Note that a rehash warning means that the operation was successfully completed. However, there may be serious problems like heap corruption, so handling this as an error is not a bad idea.
int Map_erase_map (Map_t * self, Map_t const * other)
like Map_erase on all entries in other. If any key was not found,
WARN_KEYNOTFOUND is returned.
Error Codes (Global_map_errno)
In case of operation, Global_MAP_OK is signalled.
Global_MAP_WARN_KEYNOTFOUND
Global_MAP_REHASH_*
Note that a warning means that the operation was successfully completed.
Note that a rehash warning means that the operation was successfully completed. However, there may be serious problems like heap corruption, so handling this as an error is not a bad idea.
int Map_erase_map (Map_t * self, Map_t const * other)
like Map_erase on all entries in other. If any key was not found,
WARN_KEYNOTFOUND is returned.
Error Codes (Global_map_errno)
In case of operation, Global_MAP_OK is signalled.
Global_MAP_WARN_KEYNOTFOUND
Global_MAP_REHASH_*
Note that a warning means that the operation was successfully completed.
Note that a rehash warning means that the operation was successfully completed. However, there may be serious problems like heap corruption, so handling this as an error is not a bad idea.
int Map_erase_map (Map_t * self, Map_t const * other)
like Map_erase on all entries in other. If any key was not found,
WARN_KEYNOTFOUND is returned.
Error Codes (Global_map_errno)
In case of operation, Global_MAP_OK is signalled.
Global_MAP_WARN_KEYNOTFOUND
Global_MAP_REHASH_*
Note that a warning means that the operation was successfully completed.
Note that a rehash warning means that the operation was successfully completed. However, there may be serious problems like heap corruption, so handling this as an error is not a bad idea.
int Map_erase_map (Map_t * self, Map_t const * other)
like Map_erase on all entries in other. If any key was not found,
WARN_KEYNOTFOUND is returned.
Error Codes (Global_map_errno)
In case of operation, Global_MAP_OK is signalled.
Global_MAP_WARN_KEYNOTFOUND
Global_MAP_REHASH_*
Note that a warning means that the operation was successfully completed.
Note that a rehash warning means that the operation was successfully completed. However, there may be serious problems like heap corruption, so handling this as an error is not a bad idea.
int Map_erase_if (Map_t * self, Map_feature_t feature, Global_ERWIN_BOOL value)
Erase some entries from the map according to a given feature. This
is much faster than repeated deletions and maximally requires one
rehash operation only.
Note
Even if the library is compiled with determinism, the order of the
invocations of the feature callback is non-deterministic!
int Map_intersect (Map_t * self, Map_t const * other)
Implements set intersection: this invokes Map_erase on all entries
in self that are not in other.
Returns the number of erased elements (quite like Map_erase_if).
Error Codes (Global_map_errno)
In case of operation, Global_MAP_OK is signalled.
Global_MAP_REHASH_*
If memory is exhausted, Global_MAP_ERR_NOMEM is signalled.
If the option Map_NOMEM_IS_FATAL is 1, this error cannot happen: instead, the program is immediately terminated.
Note that a rehash warning means that the operation was successfully completed. However, there may be serious problems like heap corruption, so handling this as an error is not a bad idea.
int Map_intersect (Map_t * self, Map_t const * other)
Implements set intersection: this invokes Map_erase on all entries
in self that are not in other.
Returns the number of erased elements (quite like Map_erase_if).
Error Codes (Global_map_errno)
In case of operation, Global_MAP_OK is signalled.
Global_MAP_REHASH_*
If memory is exhausted, Global_MAP_ERR_NOMEM is signalled.
If the option Map_NOMEM_IS_FATAL is 1, this error cannot happen: instead, the program is immediately terminated.
Note that a rehash warning means that the operation was successfully completed. However, there may be serious problems like heap corruption, so handling this as an error is not a bad idea.
int Map_intersect_no_resize (Map_t * self, Map_t const * other)
Like Map_intersect, but does not shrink the internal hash table.
Error Codes (Global_map_errno)
In case of operation, Global_MAP_OK is signalled.
Global_MAP_REHASH_*
If memory is exhausted, Global_MAP_ERR_NOMEM is signalled.
If the option Map_NOMEM_IS_FATAL is 1, this error cannot happen: instead, the program is immediately terminated.
Note that a rehash warning means that the operation was successfully completed. However, there may be serious problems like heap corruption, so handling this as an error is not a bad idea.
int Map_intersect_no_resize (Map_t * self, Map_t const * other)
Like Map_intersect, but does not shrink the internal hash table.
Error Codes (Global_map_errno)
In case of operation, Global_MAP_OK is signalled.
Global_MAP_REHASH_*
If memory is exhausted, Global_MAP_ERR_NOMEM is signalled.
If the option Map_NOMEM_IS_FATAL is 1, this error cannot happen: instead, the program is immediately terminated.
Note that a rehash warning means that the operation was successfully completed. However, there may be serious problems like heap corruption, so handling this as an error is not a bad idea.
This ensures that key is inserted in the table, i.e., it allocates a cell
for it. The inserted value will be Global_oType_ZERO. If you
want to change this, re-define Map_ENSURE_VALUE.
The result is the key as inserted in the hash table, so if you defined
Global_iType_ICOPY, you will get a copy of your key.
Note
This function implements symbol tables.
Error Codes (Global_map_errno)
In case of operation, Global_MAP_OK is signalled.
Global_MAP_WARN_EXISTINGKEY
Global_MAP_REHASH_*
If memory is exhausted, Global_MAP_ERR_NOMEM is signalled.
If the option Map_NOMEM_IS_FATAL is 1, this error cannot happen: instead, the program is immediately terminated.
Note that a warning means that the operation was successfully completed.
Note that a rehash warning means that the operation was successfully completed. However, there may be serious problems like heap corruption, so handling this as an error is not a bad idea.
This is like Map_ensure(), but the input key will be stolen or freed, i.e.,
it will be used as a copy inside the hash table, instead of being copied
as in Map_ensure. If the key already exists, the key passed will be freed.
Note
This function implements symbol tables.
This could be called Map_ensure_steal(), but we already have poke_no_icopy().
Error Codes (Global_map_errno)
In case of operation, Global_MAP_OK is signalled.
Global_MAP_WARN_EXISTINGKEY
Global_MAP_REHASH_*
If memory is exhausted, Global_MAP_ERR_NOMEM is signalled.
If the option Map_NOMEM_IS_FATAL is 1, this error cannot happen: instead, the program is immediately terminated.
Note that a warning means that the operation was successfully completed.
Note that a rehash warning means that the operation was successfully completed. However, there may be serious problems like heap corruption, so handling this as an error is not a bad idea.
This ensures that key is inserted in the table, i.e., it allocates a cell
for it. The inserted value will be Global_oType_ZERO. If you
want to change this, re-define Map_ENSURE_VALUE.
The result is the key as inserted in the hash table, so if you defined
Global_iType_ICOPY, you will get a copy of your key.
Note
This function implements symbol tables.
Error Codes (Global_map_errno)
In case of operation, Global_MAP_OK is signalled.
Global_MAP_WARN_EXISTINGKEY
Global_MAP_REHASH_*
If memory is exhausted, Global_MAP_ERR_NOMEM is signalled.
If the option Map_NOMEM_IS_FATAL is 1, this error cannot happen: instead, the program is immediately terminated.
Note that a warning means that the operation was successfully completed.
Note that a rehash warning means that the operation was successfully completed. However, there may be serious problems like heap corruption, so handling this as an error is not a bad idea.
Like Map_poke, but the value is not copied. However, value may be freed if
value_out is NULL. The rules for copying and freeing values are the same as
for key with Map_poke_no_icopy.
Like Map_poke, but neither the key nor the value are copied. Both, key and value
may be freed. The rules for copying and freeing keys and values are the same
as for Map_poke_no_icopy and Map_poke_no_ocopy.
Get all keys, values, or key/value pairs as a normal standard C array.
The elements and keys are not copied. The array will be terminated
with the zero value.
Note
The returned maps are newly allocated and must eventually be
freed by the user using Map_delete_keys(). In earlier versions
of Erwin, free() was recommended for freeing, but due to more
sophisticated memory management, Map_delete_keys() is the
primary choice now. It old code, no adjustment should be
necessary, since this is only different if you
customise Global_ERWIN_TMALLOC etc.
Error Codes (Global_map_errno)
In case of operation, Global_MAP_OK is signalled.
If memory is exhausted, Global_MAP_ERR_NOMEM is signalled.
If the option Map_NOMEM_IS_FATAL is 1, this error cannot happen: instead, the program is immediately terminated.
If memory is exhausted, Global_MAP_ERR_NOMEM is signalled.
If the option Map_NOMEM_IS_FATAL is 1, this error cannot happen: instead, the program is immediately terminated.
If memory is exhausted, Global_MAP_ERR_NOMEM is signalled.
If the option Map_NOMEM_IS_FATAL is 1, this error cannot happen: instead, the program is immediately terminated.
If memory is exhausted, Global_MAP_ERR_NOMEM is signalled.
If the option Map_NOMEM_IS_FATAL is 1, this error cannot happen: instead, the program is immediately terminated.
Do a manual rehash. If Global_map_errno holds anything other than MAP_OK,
the map operation did not succeed. However, the map is guaranteed to be
usable after the function call; either rehashed or original.
The return type is set to void because the function should not be
considered failed if anything bad has happened.
Error Codes (Global_map_errno)
In case of operation, Global_MAP_OK is signalled.
Global_MAP_REHASH_*
Note that a rehash warning means that the operation was successfully completed. However, there may be serious problems like heap corruption, so handling this as an error is not a bad idea.
Calculates a hash value for this hash table. In earlier versions of Erwin,
the result was inferior to that of Map_hash, but they are now the same
and no additional hashing of the result needs to be done.
Note
Calling this results in a runtime error if Global_oType_HASH is not defined.
int Map_cmp (Map_t const * self, Map_t const * other)
Returns a comparison value for the two maps. The keys must be sortable for this to
work. Maps are invariant in the actual storage order in the hash table.
Note
This operation is expensive and needs additional space for copying the
keys of self for sorting!
For equality tests, use Map_equal instead, which is faster.
The comparison value is as follows:
the map that contains most elements is assumed largest.
for equally sized maps, a lexical order is used by sorting the keys and
comparing the values of the two maps. 'Not contained' is assumed
smallest.
Further Note
Calling this results in a runtime error if either
Global_iType_CMP or Global_oType_CMP is not defined.
Error Codes (Global_map_errno)
In case of operation, Global_MAP_OK is signalled.
If memory is exhausted, Global_MAP_ERR_NOMEM is signalled.
If the option Map_NOMEM_IS_FATAL is 1, this error cannot happen: instead, the program is immediately terminated.