012345678910111213141516171819202122232425262728293031323334353637383940
|
// util/map.h, version 0.1.2
// Map utility header file from libutil
// Copyright (C) 2021, Jakob Wakeling
// MIT Licence
#ifndef UTIL_MAP_H_NB53CJJ8
#define UTIL_MAP_H_NB53CJJ8
#ifdef __cplusplus
extern "C" {
#endif
#include "util.h"
typedef struct {
struct { u64 h; char *k; void *v; } *a;
UINT al, ac; void (*free)(void *);
} map;
// #define MAP_INIT(type, free) map_init(sizeof (type), (free))
// #define MAP_INSERT(m, k, v) map_insert(m, k, (void *)(UINT)(e))
/* This should be used for debugging or testing only. */
extern UINT map_initial_capacity;
extern map map_init(void (*free)(void *));
extern void map_free(map *m);
extern void map_insert(map *m, char *k, void *v);
extern void *map_lookup(map *m, char *k);
extern void *map_remove(map *m, char *k);
extern void map_print(map *m);
extern void map_debug(map *m);
#ifdef __cplusplus
} // extern "C"
#endif
#endif // UTIL_MAP_H_NB53CJJ8
|