Scippy

SCIP

Solving Constraint Integer Programs

dpborder_hashmap.h
Go to the documentation of this file.
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2 /* */
3 /* This file is part of the program and library */
4 /* SCIP --- Solving Constraint Integer Programs */
5 /* */
6 /* Copyright (C) 2002-2022 Konrad-Zuse-Zentrum */
7 /* fuer Informationstechnik Berlin */
8 /* */
9 /* SCIP is distributed under the terms of the ZIB Academic License. */
10 /* */
11 /* You should have received a copy of the ZIB Academic License */
12 /* along with SCIP; see the file COPYING. If not visit scip.zib.de. */
13 /* */
14 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
15 
16 /**@file dpborder_hashmap.h
17  * @brief Special hashmap for DP-border Steiner tree algorithm
18  * @author Daniel Rehfeldt
19  *
20  * modified version of https://github.com/sheredom/hashmap.h
21  *
22  */
23 
24 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
25 
26 
27 #ifndef APPLICATIONS_STP_SRC_DPBORDER_HASHMAP_H_
28 #define APPLICATIONS_STP_SRC_DPBORDER_HASHMAP_H_
29 
30 #if defined(_MSC_VER)
31 // Workaround a bug in the MSVC runtime where it uses __cplusplus when not
32 // defined.
33 #pragma warning(push, 0)
34 #pragma warning(disable : 4668)
35 #endif
36 #include <stdlib.h>
37 #include <string.h>
38 #include "scip/scip.h"
39 
40 
41 #if (defined(_MSC_VER) && defined(__AVX__)) || \
42  (!defined(_MSC_VER) && defined(__SSE4_2__)) || \
43  (defined(__INTEL_COMPILER))
44 #define HASHMAP_SSE42
45 #endif
46 
47 #if defined(HASHMAP_SSE42)
48 #include <nmmintrin.h>
49 #endif
50 
51 #if defined(_MSC_VER)
52 #pragma warning(pop)
53 #endif
54 
55 #if defined(_MSC_VER)
56 #pragma warning(push)
57 /* Stop MSVC complaining about unreferenced functions */
58 #pragma warning(disable : 4505)
59 /* Stop MSVC complaining about not inlining functions */
60 #pragma warning(disable : 4710)
61 /* Stop MSVC complaining about inlining functions! */
62 #pragma warning(disable : 4711)
63 #elif defined(__clang__)
64 #pragma clang diagnostic push
65 #pragma clang diagnostic ignored "-Wunused-function"
66 #endif
67 
68 #if defined(_MSC_VER)
69 #define HASHMAP_USED
70 #elif defined(__GNUC__)
71 #define HASHMAP_USED __attribute__((used))
72 #else
73 #define HASHMAP_USED
74 #endif
75 
76 /* We need to keep keys and values. */
78  unsigned key_len;
80  int in_use;
81  int value;
82 };
83 
84 /* A hashmap has some maximum size and current size, as well as the data to
85  * hold. */
86 typedef struct hashmap_s {
87  const char* keyarray; /* non owned! */
88  unsigned table_size;
89  unsigned size;
91 } DPBHASHMAP;
92 
93 #define HASHMAP_MAX_CHAIN_LENGTH (8)
94 
95 #if defined(__cplusplus)
96 extern "C" {
97 #endif
98 
99 /// @brief Create a hashmap.
100 /// @param initial_size The initial size of the hashmap. Must be a power of two.
101 /// @param out_hashmap The storage for the created hashmap.
102 /// @param keyarr Array with keys
103 /// @return On success 0 is returned.
104 ///
105 /// Note that the initial size of the hashmap must be a power of two, and
106 /// creation of the hashmap will fail if this is not the case.
107 static SCIP_RETCODE hashmap_create(const unsigned initial_size,
108  const char* keyarr,
109  struct hashmap_s *const out_hashmap) HASHMAP_USED;
110 
111 static void hashmap_updateKeyarr(
112  const char* keyarr,
113  struct hashmap_s* out_hashmap) HASHMAP_USED;
114 
115 /// @brief Put an element into the hashmap.
116 /// @param hashmap The hashmap to insert into.
117 /// @param key_position The string key position to use.
118 /// @param len The length of the string key.
119 /// @param value The value to insert.
120 /// @return On success 0 is returned.
121 ///
122 /// The key string slice is not copied when creating the hashmap entry, and thus
123 /// must remain a valid pointer until the hashmap entry is removed or the
124 /// hashmap is destroyed.
125 static int hashmap_putcheck(struct hashmap_s *const hashmap, int key_position,
126  const unsigned len, int value) HASHMAP_USED;
127 
128 static void hashmap_put(struct hashmap_s *const hashmap, int position,
129  const unsigned len, int value) HASHMAP_USED;
130 
131 /// @brief Get an element from the hashmap.
132 /// @param hashmap The hashmap to get from.
133 /// @param position The string key position to use.
134 /// @param len The length of the string key.
135 /// @return The previously set element, or NULL if none exists.
136 static int hashmap_get(const struct hashmap_s *const hashmap, int position,
137  const unsigned len) HASHMAP_USED;
138 
139 /// @brief Remove an element from the hashmap.
140 /// @param hashmap The hashmap to remove from.
141 /// @param position The string key position to use.
142 /// @param len The length of the string key.
143 /// @return On success 0 is returned.
144 static int hashmap_remove(struct hashmap_s *const hashmap, int position,
145  const unsigned len) HASHMAP_USED;
146 
147 /// @brief Iterate over all the elements in a hashmap.
148 /// @param hashmap The hashmap to iterate over.
149 /// @param hashmap_new The new hashmap.
150 /// @return If the entire hashmap was iterated then 0 is returned.
151 static int hashmap_iterate_pairs(struct hashmap_s *const hashmap,
152  struct hashmap_s *const hashmap_new) HASHMAP_USED;
153 
154 /// @brief Get the size of the hashmap.
155 /// @param hashmap The hashmap to get the size of.
156 /// @return The size of the hashmap.
157 static unsigned
158 hashmap_num_entries(const struct hashmap_s *const hashmap) HASHMAP_USED;
159 
160 static SCIP_Bool
161 hashmap_isEmpty(const struct hashmap_s *const hashmap) HASHMAP_USED;
162 
163 /// @brief Destroy the hashmap.
164 /// @param hashmap The hashmap to destroy.
165 static void hashmap_destroy(struct hashmap_s *const hashmap) HASHMAP_USED;
166 
167 static unsigned hashmap_crc32_helper(const char *const s,
168  const unsigned len) HASHMAP_USED;
169 static unsigned hashmap_hash_helper_int_helper(const struct hashmap_s *const m,
170  const char *const keystring,
171  const unsigned len) HASHMAP_USED;
172 static int hashmap_hash_helper(const struct hashmap_s *const m,
173  int position, const unsigned len,
174  unsigned *const out_index) HASHMAP_USED;
175 static int
176 hashmap_rehash_iterator(struct hashmap_s *const m_new,
177  struct hashmap_element_s *const e) HASHMAP_USED;
178 static int hashmap_rehash_helper(struct hashmap_s *const m) HASHMAP_USED;
179 
180 #if defined(__cplusplus)
181 }
182 #endif
183 
184 #if defined(__cplusplus)
185 #define HASHMAP_CAST(type, x) static_cast<type>(x)
186 #define HASHMAP_PTR_CAST(type, x) reinterpret_cast<type>(x)
187 #define HASHMAP_NULL NULL
188 #else
189 #define HASHMAP_CAST(type, x) ((type)x)
190 #define HASHMAP_PTR_CAST(type, x) ((type)x)
191 #define HASHMAP_NULL 0
192 #endif
193 
194 static inline
195 int hashmap_match_helper(const struct hashmap_element_s *const element,
196  const char *const key, const char *const keyarr, const unsigned len) {
197  return (element->key_len == len) && (0 == memcmp(&keyarr[element->key_position], key, len));
198 }
199 
200 
201 SCIP_RETCODE hashmap_create(const unsigned initial_size,
202  const char* keyarr,
203  struct hashmap_s *const out_hashmap) {
204  out_hashmap->table_size = initial_size;
205  out_hashmap->size = 0;
206  out_hashmap->keyarray = keyarr;
207 
208  if (0 == initial_size || 0 != (initial_size & (initial_size - 1))) {
209  return SCIP_ERROR;
210  }
211 
212  out_hashmap->elements =
214  calloc(initial_size, sizeof(struct hashmap_element_s)));
215  if (!out_hashmap->elements) {
216  return SCIP_ERROR;
217  }
218 
219  return SCIP_OKAY;
220 }
221 
222 
224  const char* keyarr,
225  struct hashmap_s* out_hashmap)
226 {
227  assert(keyarr && out_hashmap);
228  out_hashmap->keyarray = keyarr;
229 }
230 
231 
232 int hashmap_putcheck(struct hashmap_s *const m, int key_position,
233  const unsigned len, int value) {
234  unsigned int index;
235  assert(key_position >= 0);
236 
237  /* Find a place to put our value. */
238  while (!hashmap_hash_helper(m, key_position, len, &index)) {
239  if (hashmap_rehash_helper(m)) {
240  return 1;
241  }
242  }
243 
244  /* Set the data. */
245  m->elements[index].key_position = key_position;
246  m->elements[index].key_len = len;
247  m->elements[index].value = value;
248 
249  /* If the hashmap element was not already in use, set that it is being used
250  * and bump our size. */
251  if (0 == m->elements[index].in_use) {
252  m->elements[index].in_use = 1;
253  m->size++;
254  }
255 
256  return 0;
257 }
258 
259 
260 void hashmap_put(struct hashmap_s *const m, int position,
261  const unsigned len, int value) {
262  unsigned int index;
263  assert(position >= 0);
264 
265  /* Find a place to put our value. */
266  while (!hashmap_hash_helper(m, position, len, &index)) {
267  if (hashmap_rehash_helper(m)) {
268  assert(0);
269  }
270  }
271 
272  /* Set the data. */
273  m->elements[index].key_position = position;
274  m->elements[index].key_len = len;
275  m->elements[index].value = value;
276 
277  /* If the hashmap element was not already in use, set that it is being used
278  * and bump our size. */
279  if (0 == m->elements[index].in_use) {
280  m->elements[index].in_use = 1;
281  m->size++;
282  }
283 }
284 
285 int hashmap_get(const struct hashmap_s *const m, int position,
286  const unsigned len) {
287  unsigned int curr;
288  unsigned int i;
289  const char* const key = &(m->keyarray[position]);
290  const struct hashmap_element_s* const elements = m->elements;
291 
292  assert(m->keyarray);
293 
294  /* Find data location */
295  curr = hashmap_hash_helper_int_helper(m, key, len);
296 
297  /* Linear probing, if necessary */
298  for (i = 0; i < HASHMAP_MAX_CHAIN_LENGTH; i++) {
299  if (elements[curr].in_use) {
300  if (hashmap_match_helper(&elements[curr], key, m->keyarray, len)) {
301  return elements[curr].value;
302  }
303  }
304 
305  curr = (curr + 1) % m->table_size;
306  }
307 
308  /* Not found */
309  return -1;
310 }
311 
312 int hashmap_remove(struct hashmap_s *const m, int position,
313  const unsigned len) {
314  unsigned int i;
315  unsigned int curr;
316  const char* const key = &(m->keyarray[position]);
317 
318  /* Find key */
319  curr = hashmap_hash_helper_int_helper(m, key, len);
320 
321  /* Linear probing, if necessary */
322  for (i = 0; i < HASHMAP_MAX_CHAIN_LENGTH; i++) {
323  if (m->elements[curr].in_use) {
324  if (hashmap_match_helper(&m->elements[curr], key, m->keyarray, len)) {
325  /* Blank out the fields including in_use */
326  memset(&m->elements[curr], 0, sizeof(struct hashmap_element_s));
327 
328  /* Reduce the size */
329  m->size--;
330 
331  return 0;
332  }
333  }
334 
335  curr = (curr + 1) % m->table_size;
336  }
337 
338  return 1;
339 }
340 
341 int hashmap_iterate_pairs(struct hashmap_s *const hashmap,
342  struct hashmap_s *const hashmap_new) {
343  unsigned int i;
344  struct hashmap_element_s *p;
345  int r;
346 
347  /* Linear probing */
348  for (i = 0; i < hashmap->table_size; i++) {
349  p = &hashmap->elements[i];
350  if (p->in_use) {
351  r = hashmap_rehash_iterator(hashmap_new, p);
352  switch (r) {
353  case -1: /* remove item */
354  memset(p, 0, sizeof(struct hashmap_element_s));
355  hashmap->size--;
356  break;
357  case 0: /* continue iterating */
358  break;
359  default: /* early exit */
360  return 1;
361  }
362  }
363  }
364  return 0;
365 }
366 
367 void hashmap_destroy(struct hashmap_s *const m) {
368  free(m->elements);
369  memset(m, 0, sizeof(struct hashmap_s));
370 }
371 
372 unsigned hashmap_num_entries(const struct hashmap_s *const m) {
373  return m->size;
374 }
375 
376 
377 SCIP_Bool hashmap_isEmpty(const struct hashmap_s *const m) {
378  return (m->size == 0);
379 }
380 
381 unsigned hashmap_crc32_helper(const char *const s, const unsigned len) {
382  unsigned i;
383  unsigned crc32val = 0;
384 
385 #if defined(HASHMAP_SSE42)
386  for (i = 0; i < len; i++) {
387  crc32val = _mm_crc32_u8(crc32val, HASHMAP_CAST(unsigned char, s[i]));
388  }
389 
390  return crc32val;
391 #else
392  // Using polynomial 0x11EDC6F41 to match SSE 4.2's crc function.
393  static const unsigned crc32_tab[] = {
394  0x00000000U, 0xF26B8303U, 0xE13B70F7U, 0x1350F3F4U, 0xC79A971FU,
395  0x35F1141CU, 0x26A1E7E8U, 0xD4CA64EBU, 0x8AD958CFU, 0x78B2DBCCU,
396  0x6BE22838U, 0x9989AB3BU, 0x4D43CFD0U, 0xBF284CD3U, 0xAC78BF27U,
397  0x5E133C24U, 0x105EC76FU, 0xE235446CU, 0xF165B798U, 0x030E349BU,
398  0xD7C45070U, 0x25AFD373U, 0x36FF2087U, 0xC494A384U, 0x9A879FA0U,
399  0x68EC1CA3U, 0x7BBCEF57U, 0x89D76C54U, 0x5D1D08BFU, 0xAF768BBCU,
400  0xBC267848U, 0x4E4DFB4BU, 0x20BD8EDEU, 0xD2D60DDDU, 0xC186FE29U,
401  0x33ED7D2AU, 0xE72719C1U, 0x154C9AC2U, 0x061C6936U, 0xF477EA35U,
402  0xAA64D611U, 0x580F5512U, 0x4B5FA6E6U, 0xB93425E5U, 0x6DFE410EU,
403  0x9F95C20DU, 0x8CC531F9U, 0x7EAEB2FAU, 0x30E349B1U, 0xC288CAB2U,
404  0xD1D83946U, 0x23B3BA45U, 0xF779DEAEU, 0x05125DADU, 0x1642AE59U,
405  0xE4292D5AU, 0xBA3A117EU, 0x4851927DU, 0x5B016189U, 0xA96AE28AU,
406  0x7DA08661U, 0x8FCB0562U, 0x9C9BF696U, 0x6EF07595U, 0x417B1DBCU,
407  0xB3109EBFU, 0xA0406D4BU, 0x522BEE48U, 0x86E18AA3U, 0x748A09A0U,
408  0x67DAFA54U, 0x95B17957U, 0xCBA24573U, 0x39C9C670U, 0x2A993584U,
409  0xD8F2B687U, 0x0C38D26CU, 0xFE53516FU, 0xED03A29BU, 0x1F682198U,
410  0x5125DAD3U, 0xA34E59D0U, 0xB01EAA24U, 0x42752927U, 0x96BF4DCCU,
411  0x64D4CECFU, 0x77843D3BU, 0x85EFBE38U, 0xDBFC821CU, 0x2997011FU,
412  0x3AC7F2EBU, 0xC8AC71E8U, 0x1C661503U, 0xEE0D9600U, 0xFD5D65F4U,
413  0x0F36E6F7U, 0x61C69362U, 0x93AD1061U, 0x80FDE395U, 0x72966096U,
414  0xA65C047DU, 0x5437877EU, 0x4767748AU, 0xB50CF789U, 0xEB1FCBADU,
415  0x197448AEU, 0x0A24BB5AU, 0xF84F3859U, 0x2C855CB2U, 0xDEEEDFB1U,
416  0xCDBE2C45U, 0x3FD5AF46U, 0x7198540DU, 0x83F3D70EU, 0x90A324FAU,
417  0x62C8A7F9U, 0xB602C312U, 0x44694011U, 0x5739B3E5U, 0xA55230E6U,
418  0xFB410CC2U, 0x092A8FC1U, 0x1A7A7C35U, 0xE811FF36U, 0x3CDB9BDDU,
419  0xCEB018DEU, 0xDDE0EB2AU, 0x2F8B6829U, 0x82F63B78U, 0x709DB87BU,
420  0x63CD4B8FU, 0x91A6C88CU, 0x456CAC67U, 0xB7072F64U, 0xA457DC90U,
421  0x563C5F93U, 0x082F63B7U, 0xFA44E0B4U, 0xE9141340U, 0x1B7F9043U,
422  0xCFB5F4A8U, 0x3DDE77ABU, 0x2E8E845FU, 0xDCE5075CU, 0x92A8FC17U,
423  0x60C37F14U, 0x73938CE0U, 0x81F80FE3U, 0x55326B08U, 0xA759E80BU,
424  0xB4091BFFU, 0x466298FCU, 0x1871A4D8U, 0xEA1A27DBU, 0xF94AD42FU,
425  0x0B21572CU, 0xDFEB33C7U, 0x2D80B0C4U, 0x3ED04330U, 0xCCBBC033U,
426  0xA24BB5A6U, 0x502036A5U, 0x4370C551U, 0xB11B4652U, 0x65D122B9U,
427  0x97BAA1BAU, 0x84EA524EU, 0x7681D14DU, 0x2892ED69U, 0xDAF96E6AU,
428  0xC9A99D9EU, 0x3BC21E9DU, 0xEF087A76U, 0x1D63F975U, 0x0E330A81U,
429  0xFC588982U, 0xB21572C9U, 0x407EF1CAU, 0x532E023EU, 0xA145813DU,
430  0x758FE5D6U, 0x87E466D5U, 0x94B49521U, 0x66DF1622U, 0x38CC2A06U,
431  0xCAA7A905U, 0xD9F75AF1U, 0x2B9CD9F2U, 0xFF56BD19U, 0x0D3D3E1AU,
432  0x1E6DCDEEU, 0xEC064EEDU, 0xC38D26C4U, 0x31E6A5C7U, 0x22B65633U,
433  0xD0DDD530U, 0x0417B1DBU, 0xF67C32D8U, 0xE52CC12CU, 0x1747422FU,
434  0x49547E0BU, 0xBB3FFD08U, 0xA86F0EFCU, 0x5A048DFFU, 0x8ECEE914U,
435  0x7CA56A17U, 0x6FF599E3U, 0x9D9E1AE0U, 0xD3D3E1ABU, 0x21B862A8U,
436  0x32E8915CU, 0xC083125FU, 0x144976B4U, 0xE622F5B7U, 0xF5720643U,
437  0x07198540U, 0x590AB964U, 0xAB613A67U, 0xB831C993U, 0x4A5A4A90U,
438  0x9E902E7BU, 0x6CFBAD78U, 0x7FAB5E8CU, 0x8DC0DD8FU, 0xE330A81AU,
439  0x115B2B19U, 0x020BD8EDU, 0xF0605BEEU, 0x24AA3F05U, 0xD6C1BC06U,
440  0xC5914FF2U, 0x37FACCF1U, 0x69E9F0D5U, 0x9B8273D6U, 0x88D28022U,
441  0x7AB90321U, 0xAE7367CAU, 0x5C18E4C9U, 0x4F48173DU, 0xBD23943EU,
442  0xF36E6F75U, 0x0105EC76U, 0x12551F82U, 0xE03E9C81U, 0x34F4F86AU,
443  0xC69F7B69U, 0xD5CF889DU, 0x27A40B9EU, 0x79B737BAU, 0x8BDCB4B9U,
444  0x988C474DU, 0x6AE7C44EU, 0xBE2DA0A5U, 0x4C4623A6U, 0x5F16D052U,
445  0xAD7D5351U};
446 
447  for (i = 0; i < len; i++) {
448  crc32val = crc32_tab[(HASHMAP_CAST(unsigned char, crc32val) ^
449  HASHMAP_CAST(unsigned char, s[i]))] ^
450  (crc32val >> 8);
451  }
452  return crc32val;
453 #endif
454 }
455 
456 unsigned hashmap_hash_helper_int_helper(const struct hashmap_s *const m,
457  const char *const keystring,
458  const unsigned len) {
459  unsigned key = hashmap_crc32_helper(keystring, len);
460 
461  /* Robert Jenkins' 32 bit Mix Function */
462  key += (key << 12);
463  key ^= (key >> 22);
464  key += (key << 4);
465  key ^= (key >> 9);
466  key += (key << 10);
467  key ^= (key >> 2);
468  key += (key << 7);
469  key ^= (key >> 12);
470 
471  /* Knuth's Multiplicative Method */
472  key = (key >> 3) * 2654435761;
473 
474  return key % m->table_size;
475 }
476 
477 int hashmap_hash_helper(const struct hashmap_s *const m, int position,
478  const unsigned len, unsigned *const out_index) {
479  unsigned int start, curr;
480  unsigned int i;
481  int total_in_use;
482  const char* const key = &(m->keyarray[position]);
483 
484  /* If full, return immediately */
485  if (m->size >= m->table_size) {
486  return 0;
487  }
488 
489  /* Find the best index */
490  curr = start = hashmap_hash_helper_int_helper(m, key, len);
491 
492  /* First linear probe to check if we've already insert the element */
493  total_in_use = 0;
494 
495  for (i = 0; i < HASHMAP_MAX_CHAIN_LENGTH; i++) {
496  const int in_use = m->elements[curr].in_use;
497 
498  total_in_use += in_use;
499 
500  if (in_use && hashmap_match_helper(&m->elements[curr], key, m->keyarray, len)) {
501  *out_index = curr;
502  return 1;
503  }
504 
505  curr = (curr + 1) % m->table_size;
506  }
507 
508  curr = start;
509 
510  /* Second linear probe to actually insert our element (only if there was at
511  * least one empty entry) */
512  if (HASHMAP_MAX_CHAIN_LENGTH > total_in_use) {
513  for (i = 0; i < HASHMAP_MAX_CHAIN_LENGTH; i++) {
514  if (!m->elements[curr].in_use) {
515  *out_index = curr;
516  return 1;
517  }
518 
519  curr = (curr + 1) % m->table_size;
520  }
521  }
522 
523  return 0;
524 }
525 
526 int hashmap_rehash_iterator(struct hashmap_s *const new_hash,
527  struct hashmap_element_s *const e) {
528  const int temp = hashmap_putcheck(new_hash, e->key_position,
529  e->key_len, e->value);
530  if (0 < temp) {
531  return 1;
532  }
533  /* clear old value to avoid stale pointers */
534  return -1;
535 }
536 
537 /*
538  * Doubles the size of the hashmap, and rehashes all the elements
539  */
540 int hashmap_rehash_helper(struct hashmap_s *const m) {
541  /* If this multiplication overflows hashmap_create will fail. */
542  unsigned new_size = 2 * m->table_size;
543  struct hashmap_s new_hash;
544  SCIP_RETCODE retcode = hashmap_create(new_size, m->keyarray, &new_hash);
545  int flag;
546 
547  printf("reallocating hash map \n");
548 
549  if (SCIP_OKAY != retcode) {
550  return 1;
551  }
552 
553  /* copy the old elements to the new table */
554  flag = hashmap_iterate_pairs(m, &new_hash);
555 
556  if (0 != flag) {
557  return flag;
558  }
559 
560  hashmap_destroy(m);
561  /* put new hash into old hash structure by copying */
562  memcpy(m, &new_hash, sizeof(struct hashmap_s));
563 
564  return 0;
565 }
566 
567 #if defined(_MSC_VER)
568 #pragma warning(pop)
569 #elif defined(__clang__)
570 #pragma clang diagnostic pop
571 #endif
572 
573 
574 
575 #endif /* APPLICATIONS_STP_SRC_DPBORDER_HASHMAP_H_ */
#define HASHMAP_MAX_CHAIN_LENGTH
static void hashmap_destroy(struct hashmap_s *const hashmap) HASHMAP_USED
Destroy the hashmap.
static void hashmap_updateKeyarr(const char *keyarr, struct hashmap_s *out_hashmap) HASHMAP_USED
struct hashmap_s DPBHASHMAP
static int hashmap_remove(struct hashmap_s *const hashmap, int position, const unsigned len) HASHMAP_USED
Remove an element from the hashmap.
unsigned size
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:54
static int hashmap_rehash_iterator(struct hashmap_s *const m_new, struct hashmap_element_s *const e) HASHMAP_USED
static int hashmap_putcheck(struct hashmap_s *const hashmap, int key_position, const unsigned len, int value) HASHMAP_USED
Put an element into the hashmap.
static int hashmap_rehash_helper(struct hashmap_s *const m) HASHMAP_USED
static int hashmap_match_helper(const struct hashmap_element_s *const element, const char *const key, const char *const keyarr, const unsigned len)
#define HASHMAP_CAST(type, x)
static SCIP_RETCODE hashmap_create(const unsigned initial_size, const char *keyarr, struct hashmap_s *const out_hashmap) HASHMAP_USED
Create a hashmap.
static int hashmap_get(const struct hashmap_s *const hashmap, int position, const unsigned len) HASHMAP_USED
Get an element from the hashmap.
const char * keyarray
Definition: graph_load.c:93
unsigned table_size
static int hashmap_hash_helper(const struct hashmap_s *const m, int position, const unsigned len, unsigned *const out_index) HASHMAP_USED
#define SCIP_Bool
Definition: def.h:84
static unsigned hashmap_hash_helper_int_helper(const struct hashmap_s *const m, const char *const keystring, const unsigned len) HASHMAP_USED
struct hashmap_element_s * elements
static int hashmap_iterate_pairs(struct hashmap_s *const hashmap, struct hashmap_s *const hashmap_new) HASHMAP_USED
Iterate over all the elements in a hashmap.
static void hashmap_put(struct hashmap_s *const hashmap, int position, const unsigned len, int value) HASHMAP_USED
static unsigned hashmap_crc32_helper(const char *const s, const unsigned len) HASHMAP_USED
SCIP_Real * r
Definition: circlepacking.c:50
static SCIP_Bool hashmap_isEmpty(const struct hashmap_s *const hashmap) HASHMAP_USED
#define HASHMAP_USED
static unsigned hashmap_num_entries(const struct hashmap_s *const hashmap) HASHMAP_USED
Get the size of the hashmap.
SCIP callable library.