Rabbit Tree
Radix bit tries for implementing associative arrays and sets in C.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
common.h
Go to the documentation of this file.
1 
175 #ifndef RBT_HEADER_COMMON
176 #define RBT_HEADER_COMMON
177 
178 #include <limits.h>
179 
184 #define BYTE_T char
185 
190 #define BITS_PER_BYTE CHAR_BIT
191 
192 
203 #define MIN(a,b) (((a) < (b)) ? (a) : (b))
204 
215 #define MAX(a,b) (((a) > (b)) ? (a) : (b))
216 
217 
228 #define RBT_TOKEN_2(a,b) a ## b
229 
240 #define RBT_TOKEN_2_W(a,b) RBT_TOKEN_2(a,b)
241 
253 #define _RBT_TOKEN_2(a,b) _ ## a ## b
254 
265 #define _RBT_TOKEN_2_W(a,b) _RBT_TOKEN_2(a,b)
266 
274 #define MOST_SIGNIFICANT_BIT(x) (((x) ~ 0) ^ (((x) ~ 0) >> 1))
275 
283 #define MOST_SIGNIFICANT_BIT_W(x) MOST_SIGNIFICANT_BIT(x)
284 
292 #define FIRST_BIT_IS_1(x) (MOST_SIGNIFICANT_BIT(typeof(x)) & (x))
293 
304 #define N_BIT_IS_1(x,n) (MOST_SIGNIFICANT_BIT(typeof(x)) & (x << n))
305 
319 #define DIV_UP(x,y) ((x) ? (1 + (x-1)/y) : 0)
320 
321 
322 
323 
324 
329 typedef enum
330 {
335 
341 
347 
365 }
367 
368 
376 const char *
378 {
379  switch (action)
380  {
382  return "NOTHING";
383  break;
384 
386  return "INSERT";
387  break;
388 
390  return "INSERT OR REPLACE";
391  break;
392 
393  default:
394  return "UNKNOWN ACTION";
395  break;
396  }
397 }
398 
399 
400 
401 
402 
407 typedef enum
408 {
413 
418 
423 
428 
436 }
438 
439 
447 const char *
449 {
450  switch (action)
451  {
453  return "DELETE";
454  break;
455 
457  return "INSERT";
458  break;
459 
461  return "RETRIEVE";
462  break;
463 
465  return "RBT_QUERY_ACTION_RETRIEVE_AND_INSERT";
466  break;
467 
469  return "SWAP";
470  break;
471 
472  default:
473  return "UNKNOWN ACTION";
474  break;
475  }
476 }
477 
478 #endif // RBT_HEADER_COMMON
Definition: common.h:364
rbt_query_action_t
Query action for RBT_NODE_QUERY().
Definition: common.h:407
rbt_retrieve_action_t
Retrieval action for RBT_NODE_RETRIEVE().
Definition: common.h:329
Definition: common.h:334
const char * rbt_retrieve_action_string(rbt_retrieve_action_t action)
Return a string representing a retrieval action.
Definition: common.h:377
const char * rbt_query_action_string(rbt_query_action_t action)
Return a string representing a query action.
Definition: common.h:448
Definition: common.h:412
Definition: common.h:417
Definition: common.h:340
Definition: common.h:427
Definition: common.h:422
Definition: common.h:435