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 
55 #define HT_INIT_SIZE 16
56 
63 typedef struct hashtable_S {
65  size_t ht_used;
67  size_t ht_filled;
68  int ht_locked;
72 } hashtab_T;
73 
79 #define HASHTAB_ITER(ht, hi, code) \
80  do { \
81  hashtab_T *const hi##ht_ = (ht); \
82  size_t hi##todo_ = hi##ht_->ht_used; \
83  for (hashitem_T *hi = hi##ht_->ht_array; hi##todo_; hi++) { \
84  if (!HASHITEM_EMPTY(hi)) { \
85  hi##todo_--; \
86  { \
87  code \
88  } \
89  } \
90  } \
91  } while (0)
92 
93 #ifdef INCLUDE_GENERATED_DECLARATIONS
94 # include "hashtab.h.generated.h"
95 #endif
96 
97 #endif // NVIM_HASHTAB_H
types.h
hashtable_S::ht_used
size_t ht_used
Definition: hashtab.h:66
hashtable_S
Definition: hashtab.h:63
HT_INIT_SIZE
#define HT_INIT_SIZE
Definition: hashtab.h:55
hashtable_S::ht_array
hashitem_T * ht_array
counter for hash_lock()
Definition: hashtab.h:69
hash_removed
char hash_removed
Definition: hashtab.c:42
hashitem_S::hi_hash
hash_T hi_hash
Cached hash number for hi_key.
Definition: hashtab.h:40
hashtable_S::ht_mask
hash_T ht_mask
Definition: hashtab.h:64
hashtab_T
struct hashtable_S hashtab_T
hashitem_S::hi_key
char_u * hi_key
Definition: hashtab.h:48
hashtable_S::ht_locked
int ht_locked
number of items used or removed
Definition: hashtab.h:68
hash_T
size_t hash_T
Type for hash number (hash calculation result).
Definition: hashtab.h:14
char_u
unsigned char char_u
Definition: types.h:12
hashtable_S::ht_filled
size_t ht_filled
number of items used
Definition: hashtab.h:67
hashtable_S::ht_smallarray
hashitem_T ht_smallarray[HT_INIT_SIZE]
Definition: hashtab.h:71
hashitem_T
struct hashitem_S hashitem_T
hashitem_S
Definition: hashtab.h:38