hashtab.h
Go to the documentation of this file.
1 #ifndef NVIM_HASHTAB_H
2 #define NVIM_HASHTAB_H
3 
4 #include <stddef.h>
5 
6 #include "nvim/types.h"
7 
11 extern char hash_removed;
12 
14 typedef size_t hash_T;
15 
18 #define HI_KEY_REMOVED ((char_u *)&hash_removed)
19 #define HASHITEM_EMPTY(hi) ((hi)->hi_key == NULL \
20  || (hi)->hi_key == (char_u *)&hash_removed)
21 
38 typedef struct hashitem_S {
41 
49 } hashitem_T;
50 
54 #define HT_INIT_SIZE 16
55 
62 typedef struct hashtable_S {
64  size_t ht_used;
66  size_t ht_filled;
67  int ht_locked;
69  hashitem_T ht_smallarray[HT_INIT_SIZE];
71 } hashtab_T;
72 
78 #define HASHTAB_ITER(ht, hi, code) \
79  do { \
80  hashtab_T *const hi##ht_ = (ht); \
81  size_t hi##todo_ = hi##ht_->ht_used; \
82  for (hashitem_T *hi = hi##ht_->ht_array; hi##todo_; hi++) { \
83  if (!HASHITEM_EMPTY(hi)) { \
84  hi##todo_--; \
85  { \
86  code \
87  } \
88  } \
89  } \
90  } while (0)
91 
92 #ifdef INCLUDE_GENERATED_DECLARATIONS
93 # include "hashtab.h.generated.h"
94 #endif
95 
96 #endif // NVIM_HASHTAB_H
int ht_locked
number of items used or removed
Definition: hashtab.h:67
struct hashitem_S hashitem_T
#define HT_INIT_SIZE
Definition: hashtab.h:54
char_u * hi_key
Definition: hashtab.h:48
char hash_removed
Definition: hashtab.c:42
hash_T ht_mask
Definition: hashtab.h:63
struct hashtable_S hashtab_T
Definition: hashtab.h:62
unsigned char char_u
Definition: types.h:11
size_t hash_T
Type for hash number (hash calculation result).
Definition: hashtab.h:14
size_t ht_filled
number of items used
Definition: hashtab.h:66
hashitem_T * ht_array
counter for hash_lock()
Definition: hashtab.h:68
Definition: hashtab.h:38
hash_T hi_hash
Cached hash number for hi_key.
Definition: hashtab.h:40