reactor-c
C Runtime for Lingua Franca
Loading...
Searching...
No Matches
pointer_hashmap.h File Reference
#include "hashmap.h"

Go to the source code of this file.

Macros

#define HASHMAP(token)
 Defines a hashmap type that maps void pointers to integers. To use this:
 
#define K   void*
 
#define V   int
 
#define HASH_OF(key)
 

Macro Definition Documentation

◆ HASH_OF

#define HASH_OF ( key)
Value:
(size_t) key
static K key
Definition hashmap.h:70

◆ HASHMAP

#define HASHMAP ( token)
Value:
hashmap_object2int##_##token
#define _(c)

Defines a hashmap type that maps void pointers to integers. To use this:

Author
Peter Donovan (peter.nosp@m.dono.nosp@m.van@b.nosp@m.erke.nosp@m.ley.e.nosp@m.du) To create a new hashmap:
hashmap_object2int_t my_map = hashmap_object2int_new(CAPACITY, NOTHING);
#define CAPACITY
Definition hashmap_test.c:8
where CAPACITY is the maximum capacity of the hashmap and NOTHING is a pointer key that is guaranteed to be never used (e.g., NULL). To put an entry into the hashmap:
hashmap_object2int_put(POINTER, VALUE);
where POINTER is a pointer not equal to NOTHING and VALUE is an integer. This will segfault if the hashmap is already at capacity.

To retrieve a value from the hashmap:

int value = hashmap_object2int_get(POINTER);

This will segfault if the entry is not in the hashmap.

See hashmap.h for documentation on how to declare other hashmap types.

◆ K

#define K   void*

◆ V

#define V   int