Blender  V2.93
edgehash.c
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  */
16 
26 #include <limits.h>
27 #include <stdio.h>
28 #include <stdlib.h>
29 #include <string.h>
30 
31 #include "MEM_guardedalloc.h"
32 
33 #include "BLI_edgehash.h"
34 #include "BLI_strict_flags.h"
35 #include "BLI_utildefines.h"
36 
37 typedef struct _EdgeHash_Edge Edge;
38 typedef struct _EdgeHash_Entry EdgeHashEntry;
39 
40 typedef struct EdgeHash {
48 
49 typedef struct EdgeSet {
56 
57 /* -------------------------------------------------------------------- */
61 #define ENTRIES_CAPACITY(container) (uint)(1 << (container)->capacity_exp)
62 #define MAP_CAPACITY(container) (uint)(1 << ((container)->capacity_exp + 1))
63 #define CLEAR_MAP(container) \
64  memset((container)->map, 0xFF, sizeof(int32_t) * MAP_CAPACITY(container))
65 #define UPDATE_SLOT_MASK(container) \
66  { \
67  (container)->slot_mask = MAP_CAPACITY(container) - 1; \
68  } \
69  ((void)0)
70 #define PERTURB_SHIFT 5
71 
72 #define ITER_SLOTS(CONTAINER, EDGE, SLOT, INDEX) \
73  uint32_t hash = calc_edge_hash(EDGE); \
74  uint32_t mask = (CONTAINER)->slot_mask; \
75  uint32_t perturb = hash; \
76  int32_t *map = (CONTAINER)->map; \
77  uint32_t SLOT = mask & hash; \
78  int INDEX = map[SLOT]; \
79  for (;; SLOT = mask & ((5 * SLOT) + 1 + perturb), perturb >>= PERTURB_SHIFT, INDEX = map[SLOT])
80 
81 #define SLOT_EMPTY -1
82 #define SLOT_DUMMY -2
83 
84 #define CAPACITY_EXP_DEFAULT 3
85 
88 /* -------------------------------------------------------------------- */
93 {
94  return (edge.v_low << 8) ^ edge.v_high;
95 }
96 
98 {
99  /* If there are use cases where we need this it could be removed (or flag to allow),
100  * for now this helps avoid incorrect usage (creating degenerate geometry). */
101  BLI_assert(v0 != v1);
102  Edge edge;
103  if (v0 < v1) {
104  edge.v_low = v0;
105  edge.v_high = v1;
106  }
107  else {
108  edge.v_low = v1;
109  edge.v_high = v0;
110  }
111  return edge;
112 }
113 
115 {
116  return memcmp(&e1, &e2, sizeof(Edge)) == 0;
117 }
118 
120 {
121  uint result = 1;
122  while (reserve >>= 1) {
123  result++;
124  }
125  return result;
126 }
127 
130 /* -------------------------------------------------------------------- */
134 #define EH_INDEX_HAS_EDGE(eh, index, edge) \
135  ((index) >= 0 && edges_equal((edge), (eh)->entries[index].edge))
136 
137 static void edgehash_free_values(EdgeHash *eh, EdgeHashFreeFP free_value)
138 {
139  if (free_value) {
140  for (uint i = 0; i < eh->length; i++) {
141  free_value(eh->entries[i].value);
142  }
143  }
144 }
145 
146 BLI_INLINE void edgehash_insert_index(EdgeHash *eh, Edge edge, uint entry_index)
147 {
148  ITER_SLOTS (eh, edge, slot, index) {
149  if (index == SLOT_EMPTY) {
150  eh->map[slot] = (int32_t)entry_index;
151  break;
152  }
153  }
154 }
155 
157 {
158  EdgeHashEntry *entry = &eh->entries[eh->length];
159  entry->edge = edge;
160  entry->value = value;
161  eh->map[slot] = (int32_t)eh->length;
162  eh->length++;
163  return entry;
164 }
165 
167 {
168  if (UNLIKELY(ENTRIES_CAPACITY(eh) <= eh->length + eh->dummy_count)) {
169  eh->capacity_exp++;
170  UPDATE_SLOT_MASK(eh);
171  eh->dummy_count = 0;
172  eh->entries = MEM_reallocN(eh->entries, sizeof(EdgeHashEntry) * ENTRIES_CAPACITY(eh));
173  eh->map = MEM_reallocN(eh->map, sizeof(int32_t) * MAP_CAPACITY(eh));
174  CLEAR_MAP(eh);
175  for (uint i = 0; i < eh->length; i++) {
176  edgehash_insert_index(eh, eh->entries[i].edge, i);
177  }
178  return true;
179  }
180  return false;
181 }
182 
184 {
185  ITER_SLOTS (eh, edge, slot, index) {
186  if (index == SLOT_EMPTY) {
187  return edgehash_insert_at_slot(eh, slot, edge, value);
188  }
189  if (index == SLOT_DUMMY) {
190  eh->dummy_count--;
191  return edgehash_insert_at_slot(eh, slot, edge, value);
192  }
193  }
194 }
195 
197 {
198  Edge edge = init_edge(v0, v1);
199 
200  ITER_SLOTS (eh, edge, slot, index) {
201  if (EH_INDEX_HAS_EDGE(eh, index, edge)) {
202  return &eh->entries[index];
203  }
204  if (index == SLOT_EMPTY) {
205  return NULL;
206  }
207  }
208 }
209 
210 BLI_INLINE void edgehash_change_index(EdgeHash *eh, Edge edge, int new_index)
211 {
212  ITER_SLOTS (eh, edge, slot, index) {
213  if (EH_INDEX_HAS_EDGE(eh, index, edge)) {
214  eh->map[slot] = new_index;
215  break;
216  }
217  }
218 }
219 
222 /* -------------------------------------------------------------------- */
226 EdgeHash *BLI_edgehash_new_ex(const char *info, const uint reserve)
227 {
228  EdgeHash *eh = MEM_mallocN(sizeof(EdgeHash), info);
230  UPDATE_SLOT_MASK(eh);
231  eh->length = 0;
232  eh->dummy_count = 0;
233  eh->entries = MEM_calloc_arrayN(sizeof(EdgeHashEntry), ENTRIES_CAPACITY(eh), "eh entries");
234  eh->map = MEM_malloc_arrayN(sizeof(int32_t), MAP_CAPACITY(eh), "eh map");
235  CLEAR_MAP(eh);
236  return eh;
237 }
238 
239 EdgeHash *BLI_edgehash_new(const char *info)
240 {
241  return BLI_edgehash_new_ex(info, 1 << CAPACITY_EXP_DEFAULT);
242 }
243 
245 {
246  edgehash_free_values(eh, free_value);
247  MEM_freeN(eh->map);
248  MEM_freeN(eh->entries);
249  MEM_freeN(eh);
250 }
251 
253 {
254  printf("Edgehash at %p:\n", eh);
255  printf(" Map:\n");
256  for (uint i = 0; i < MAP_CAPACITY(eh); i++) {
257  int index = eh->map[i];
258  printf(" %u: %d", i, index);
259  if (index >= 0) {
260  EdgeHashEntry entry = eh->entries[index];
261  printf(" -> (%u, %u) -> %p", entry.edge.v_low, entry.edge.v_high, entry.value);
262  }
263  printf("\n");
264  }
265  printf(" Entries:\n");
266  for (uint i = 0; i < ENTRIES_CAPACITY(eh); i++) {
267  if (i == eh->length) {
268  printf(" **** below is rest capacity ****\n");
269  }
270  EdgeHashEntry entry = eh->entries[i];
271  printf(" %u: (%u, %u) -> %p\n", i, entry.edge.v_low, entry.edge.v_high, entry.value);
272  }
273 }
274 
279 void BLI_edgehash_insert(EdgeHash *eh, uint v0, uint v1, void *value)
280 {
282  Edge edge = init_edge(v0, v1);
283  edgehash_insert(eh, edge, value);
284 }
285 
289 bool BLI_edgehash_reinsert(EdgeHash *eh, uint v0, uint v1, void *value)
290 {
291  Edge edge = init_edge(v0, v1);
292 
293  ITER_SLOTS (eh, edge, slot, index) {
294  if (EH_INDEX_HAS_EDGE(eh, index, edge)) {
295  eh->entries[index].value = value;
296  return false;
297  }
298  if (index == SLOT_EMPTY) {
299  if (edgehash_ensure_can_insert(eh)) {
300  edgehash_insert(eh, edge, value);
301  }
302  else {
303  edgehash_insert_at_slot(eh, slot, edge, value);
304  }
305  return true;
306  }
307  }
308 }
309 
313 void *BLI_edgehash_lookup_default(EdgeHash *eh, uint v0, uint v1, void *default_value)
314 {
315  EdgeHashEntry *entry = edgehash_lookup_entry(eh, v0, v1);
316  return entry ? entry->value : default_value;
317 }
318 
326 {
327  EdgeHashEntry *entry = edgehash_lookup_entry(eh, v0, v1);
328  return entry ? entry->value : NULL;
329 }
330 
336 {
337  EdgeHashEntry *entry = edgehash_lookup_entry(eh, v0, v1);
338  return entry ? &entry->value : NULL;
339 }
340 
355 bool BLI_edgehash_ensure_p(EdgeHash *eh, uint v0, uint v1, void ***r_value)
356 {
357  Edge edge = init_edge(v0, v1);
358 
359  ITER_SLOTS (eh, edge, slot, index) {
360  if (EH_INDEX_HAS_EDGE(eh, index, edge)) {
361  *r_value = &eh->entries[index].value;
362  return true;
363  }
364  if (index == SLOT_EMPTY) {
365  if (edgehash_ensure_can_insert(eh)) {
366  *r_value = &edgehash_insert(eh, edge, NULL)->value;
367  }
368  else {
369  *r_value = &edgehash_insert_at_slot(eh, slot, edge, NULL)->value;
370  }
371  return false;
372  }
373  }
374 }
375 
384 {
385  uint old_length = eh->length;
386  void *value = BLI_edgehash_popkey(eh, v0, v1);
387  if (free_value && value) {
388  free_value(value);
389  }
390  return old_length > eh->length;
391 }
392 
393 /* same as above but return the value,
394  * no free value argument since it will be returned */
402 {
403  Edge edge = init_edge(v0, v1);
404 
405  ITER_SLOTS (eh, edge, slot, index) {
406  if (EH_INDEX_HAS_EDGE(eh, index, edge)) {
407  void *value = eh->entries[index].value;
408  eh->length--;
409  eh->dummy_count++;
410  eh->map[slot] = SLOT_DUMMY;
411  eh->entries[index] = eh->entries[eh->length];
412  if ((uint)index < eh->length) {
413  edgehash_change_index(eh, eh->entries[index].edge, index);
414  }
415  return value;
416  }
417  if (index == SLOT_EMPTY) {
418  return NULL;
419  }
420  }
421 }
422 
427 {
428  return edgehash_lookup_entry(eh, v0, v1) != NULL;
429 }
430 
435 {
436  return (int)eh->length;
437 }
438 
442 void BLI_edgehash_clear_ex(EdgeHash *eh, EdgeHashFreeFP free_value, const uint UNUSED(reserve))
443 {
444  /* TODO: handle reserve */
445  edgehash_free_values(eh, free_value);
446  eh->length = 0;
447  eh->dummy_count = 0;
449  CLEAR_MAP(eh);
450 }
451 
456 {
457  BLI_edgehash_clear_ex(eh, free_value, 0);
458 }
459 
462 /* -------------------------------------------------------------------- */
472 {
473  EdgeHashIterator *ehi = MEM_mallocN(sizeof(EdgeHashIterator), __func__);
474  BLI_edgehashIterator_init(ehi, eh);
475  return ehi;
476 }
477 
487 {
488  ehi->entries = eh->entries;
489  ehi->length = eh->length;
490  ehi->index = 0;
491 }
492 
497 {
498  MEM_freeN(ehi);
499 }
500 
503 /* -------------------------------------------------------------------- */
509 #define ES_INDEX_HAS_EDGE(es, index, edge) \
510  (index) >= 0 && edges_equal((edge), (es)->entries[index])
511 
512 EdgeSet *BLI_edgeset_new_ex(const char *info, const uint reserve)
513 {
514  EdgeSet *es = MEM_mallocN(sizeof(EdgeSet), info);
516  UPDATE_SLOT_MASK(es);
517  es->length = 0;
518  es->entries = MEM_malloc_arrayN(sizeof(Edge), ENTRIES_CAPACITY(es), "es entries");
519  es->map = MEM_malloc_arrayN(sizeof(int32_t), MAP_CAPACITY(es), "es map");
520  CLEAR_MAP(es);
521  return es;
522 }
523 
524 EdgeSet *BLI_edgeset_new(const char *info)
525 {
526  return BLI_edgeset_new_ex(info, 1 << CAPACITY_EXP_DEFAULT);
527 }
528 
530 {
531  MEM_freeN(es->entries);
532  MEM_freeN(es->map);
533  MEM_freeN(es);
534 }
535 
537 {
538  return (int)es->length;
539 }
540 
541 static void edgeset_insert_index(EdgeSet *es, Edge edge, uint entry_index)
542 {
543  ITER_SLOTS (es, edge, slot, index) {
544  if (index == SLOT_EMPTY) {
545  es->map[slot] = (int)entry_index;
546  break;
547  }
548  }
549 }
550 
552 {
553  if (UNLIKELY(ENTRIES_CAPACITY(es) <= es->length)) {
554  es->capacity_exp++;
555  UPDATE_SLOT_MASK(es);
556  es->entries = MEM_reallocN(es->entries, sizeof(Edge) * ENTRIES_CAPACITY(es));
557  es->map = MEM_reallocN(es->map, sizeof(int32_t) * MAP_CAPACITY(es));
558  CLEAR_MAP(es);
559  for (uint i = 0; i < es->length; i++) {
560  edgeset_insert_index(es, es->entries[i], i);
561  }
562  }
563 }
564 
566 {
567  es->entries[es->length] = edge;
568  es->map[slot] = (int)es->length;
569  es->length++;
570 }
571 
579 {
581  Edge edge = init_edge(v0, v1);
582 
583  ITER_SLOTS (es, edge, slot, index) {
584  if (ES_INDEX_HAS_EDGE(es, index, edge)) {
585  return false;
586  }
587  if (index == SLOT_EMPTY) {
588  edgeset_insert_at_slot(es, slot, edge);
589  return true;
590  }
591  }
592 }
593 
599 {
601  Edge edge = init_edge(v0, v1);
602 
603  ITER_SLOTS (es, edge, slot, index) {
604  if (index == SLOT_EMPTY) {
605  edgeset_insert_at_slot(es, slot, edge);
606  return;
607  }
608  }
609 }
610 
612 {
613  Edge edge = init_edge(v0, v1);
614 
615  ITER_SLOTS (es, edge, slot, index) {
616  if (ES_INDEX_HAS_EDGE(es, index, edge)) {
617  return true;
618  }
619  if (index == SLOT_EMPTY) {
620  return false;
621  }
622  }
623 }
624 
626 {
627  EdgeSetIterator *esi = MEM_mallocN(sizeof(EdgeSetIterator), __func__);
628  esi->edges = es->entries;
629  esi->length = es->length;
630  esi->index = 0;
631  return esi;
632 }
633 
635 {
636  MEM_freeN(esi);
637 }
638 
#define BLI_assert(a)
Definition: BLI_assert.h:58
#define BLI_INLINE
void(* EdgeHashFreeFP)(void *key)
Definition: BLI_edgehash.h:48
Strict compiler flags for areas of code we want to ensure don't do conversions without us knowing abo...
unsigned int uint
Definition: BLI_sys_types.h:83
#define UNUSED(x)
#define UNLIKELY(x)
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble v1
Read Guarded memory(de)allocation.
#define MEM_reallocN(vmemh, len)
SIMD_FORCE_INLINE btScalar length(const btQuaternion &q)
Return the length of a quaternion.
Definition: btQuaternion.h:895
void BLI_edgehash_free(EdgeHash *eh, EdgeHashFreeFP free_value)
Definition: edgehash.c:244
EdgeHash * BLI_edgehash_new_ex(const char *info, const uint reserve)
Definition: edgehash.c:226
BLI_INLINE Edge init_edge(uint v0, uint v1)
Definition: edgehash.c:97
BLI_INLINE EdgeHashEntry * edgehash_insert(EdgeHash *eh, Edge edge, void *value)
Definition: edgehash.c:183
#define MAP_CAPACITY(container)
Definition: edgehash.c:62
void * BLI_edgehash_lookup(EdgeHash *eh, uint v0, uint v1)
Definition: edgehash.c:325
bool BLI_edgeset_haskey(EdgeSet *es, uint v0, uint v1)
Definition: edgehash.c:611
BLI_INLINE void edgehash_change_index(EdgeHash *eh, Edge edge, int new_index)
Definition: edgehash.c:210
void BLI_edgehash_insert(EdgeHash *eh, uint v0, uint v1, void *value)
Definition: edgehash.c:279
BLI_INLINE void edgehash_insert_index(EdgeHash *eh, Edge edge, uint entry_index)
Definition: edgehash.c:146
void * BLI_edgehash_lookup_default(EdgeHash *eh, uint v0, uint v1, void *default_value)
Definition: edgehash.c:313
void ** BLI_edgehash_lookup_p(EdgeHash *eh, uint v0, uint v1)
Definition: edgehash.c:335
void BLI_edgehash_print(EdgeHash *eh)
Definition: edgehash.c:252
BLI_INLINE void edgeset_ensure_can_insert(EdgeSet *es)
Definition: edgehash.c:551
static void edgeset_insert_index(EdgeSet *es, Edge edge, uint entry_index)
Definition: edgehash.c:541
#define CAPACITY_EXP_DEFAULT
Definition: edgehash.c:84
static void edgehash_free_values(EdgeHash *eh, EdgeHashFreeFP free_value)
Definition: edgehash.c:137
bool BLI_edgehash_reinsert(EdgeHash *eh, uint v0, uint v1, void *value)
Definition: edgehash.c:289
void BLI_edgesetIterator_free(EdgeSetIterator *esi)
Definition: edgehash.c:634
EdgeSet * BLI_edgeset_new_ex(const char *info, const uint reserve)
Definition: edgehash.c:512
struct EdgeSet EdgeSet
void BLI_edgehashIterator_init(EdgeHashIterator *ehi, EdgeHash *eh)
Definition: edgehash.c:486
void BLI_edgeset_free(EdgeSet *es)
Definition: edgehash.c:529
#define SLOT_DUMMY
Definition: edgehash.c:82
void BLI_edgehash_clear(EdgeHash *eh, EdgeHashFreeFP free_value)
Definition: edgehash.c:455
EdgeSet * BLI_edgeset_new(const char *info)
Definition: edgehash.c:524
void BLI_edgehashIterator_free(EdgeHashIterator *ehi)
Definition: edgehash.c:496
#define CLEAR_MAP(container)
Definition: edgehash.c:63
#define ENTRIES_CAPACITY(container)
Definition: edgehash.c:61
BLI_INLINE EdgeHashEntry * edgehash_lookup_entry(EdgeHash *eh, uint v0, uint v1)
Definition: edgehash.c:196
EdgeHashIterator * BLI_edgehashIterator_new(EdgeHash *eh)
Definition: edgehash.c:471
EdgeSetIterator * BLI_edgesetIterator_new(EdgeSet *es)
Definition: edgehash.c:625
void * BLI_edgehash_popkey(EdgeHash *eh, uint v0, uint v1)
Definition: edgehash.c:401
int BLI_edgehash_len(EdgeHash *eh)
Definition: edgehash.c:434
#define EH_INDEX_HAS_EDGE(eh, index, edge)
Definition: edgehash.c:134
int BLI_edgeset_len(EdgeSet *es)
Definition: edgehash.c:536
BLI_INLINE EdgeHashEntry * edgehash_insert_at_slot(EdgeHash *eh, uint slot, Edge edge, void *value)
Definition: edgehash.c:156
bool BLI_edgehash_remove(EdgeHash *eh, uint v0, uint v1, EdgeHashFreeFP free_value)
Definition: edgehash.c:383
struct EdgeHash EdgeHash
static uint calc_capacity_exp_for_reserve(uint reserve)
Definition: edgehash.c:119
#define UPDATE_SLOT_MASK(container)
Definition: edgehash.c:65
#define ITER_SLOTS(CONTAINER, EDGE, SLOT, INDEX)
Definition: edgehash.c:72
BLI_INLINE bool edges_equal(Edge e1, Edge e2)
Definition: edgehash.c:114
bool BLI_edgehash_ensure_p(EdgeHash *eh, uint v0, uint v1, void ***r_value)
Definition: edgehash.c:355
BLI_INLINE uint32_t calc_edge_hash(Edge edge)
Definition: edgehash.c:92
bool BLI_edgeset_add(EdgeSet *es, uint v0, uint v1)
Definition: edgehash.c:578
bool BLI_edgehash_haskey(EdgeHash *eh, uint v0, uint v1)
Definition: edgehash.c:426
EdgeHash * BLI_edgehash_new(const char *info)
Definition: edgehash.c:239
void BLI_edgeset_insert(EdgeSet *es, uint v0, uint v1)
Definition: edgehash.c:598
#define SLOT_EMPTY
Definition: edgehash.c:81
BLI_INLINE void edgeset_insert_at_slot(EdgeSet *es, uint slot, Edge edge)
Definition: edgehash.c:565
void BLI_edgehash_clear_ex(EdgeHash *eh, EdgeHashFreeFP free_value, const uint UNUSED(reserve))
Definition: edgehash.c:442
#define ES_INDEX_HAS_EDGE(es, index, edge)
Definition: edgehash.c:509
BLI_INLINE bool edgehash_ensure_can_insert(EdgeHash *eh)
Definition: edgehash.c:166
void *(* MEM_malloc_arrayN)(size_t len, size_t size, const char *str)
Definition: mallocn.c:48
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:41
void *(* MEM_calloc_arrayN)(size_t len, size_t size, const char *str)
Definition: mallocn.c:46
void *(* MEM_mallocN)(size_t len, const char *str)
Definition: mallocn.c:47
unsigned int uint32_t
Definition: stdint.h:83
signed int int32_t
Definition: stdint.h:80
struct _EdgeHash_Entry * entries
Definition: BLI_edgehash.h:43
uint32_t slot_mask
Definition: edgehash.c:43
EdgeHashEntry * entries
Definition: edgehash.c:41
uint capacity_exp
Definition: edgehash.c:44
int32_t * map
Definition: edgehash.c:42
uint length
Definition: edgehash.c:45
uint dummy_count
Definition: edgehash.c:46
struct _EdgeHash_Edge * edges
Definition: BLI_edgehash.h:123
int32_t * map
Definition: edgehash.c:51
Edge * entries
Definition: edgehash.c:50
uint32_t slot_mask
Definition: edgehash.c:52
uint length
Definition: edgehash.c:54
uint capacity_exp
Definition: edgehash.c:53
Definition: BLI_edgehash.h:37
struct _EdgeHash_Edge edge
Definition: BLI_edgehash.h:38
void * value
Definition: BLI_edgehash.h:39