Improve map module: Change scopes

- Move `Map` structure definition to `map_defs.h`
- Use `KHASH_DECLARE` on map_defs.h to declare khash function prototypes.
- Redefine `map_foreach` into a macro
- Refactor server.c module to use the new `map_foreach` macro.
This commit is contained in:
Thiago de Arruda
2014-05-19 10:52:04 -03:00
parent eb7513bbd2
commit 974eade1a6
4 changed files with 27 additions and 43 deletions

View File

@@ -47,11 +47,11 @@ void *map_put(Map *map, const char *key, void *value);
/// @return The current value if exists or NULL otherwise
void *map_del(Map *map, const char *key);
/// Iterates through each key/value pair in the map
///
/// @param map The `Map` instance
/// @param cb A function that will be called for each key/value
void map_foreach(Map *map, key_value_cb cb);
#define map_foreach(map, key, value, block) \
kh_foreach(map->table, key, value, block)
#define map_foreach_value(map, value, block) \
kh_foreach_value(map->table, value, block)
#endif // NVIM_MAP_H