hashtable_8h_source.tex 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. \hypertarget{hashtable_8h_source}{}\doxysection{hashtable.\+h}
  2. \label{hashtable_8h_source}\index{include/toolbox/hashtable.h@{include/toolbox/hashtable.h}}
  3. \begin{DoxyCode}{0}
  4. \DoxyCodeLine{1 \textcolor{preprocessor}{\#ifndef TOOLBOX\_HASHTABLE\_H}}
  5. \DoxyCodeLine{2 \textcolor{preprocessor}{\#define TOOLBOX\_HASHTABLE\_H}}
  6. \DoxyCodeLine{3 }
  7. \DoxyCodeLine{4 \textcolor{preprocessor}{\#include "{}toolbox/return\_codes.h"{}}}
  8. \DoxyCodeLine{5 }
  9. \DoxyCodeLine{6 \textcolor{preprocessor}{\#include <stdbool.h>}}
  10. \DoxyCodeLine{7 \textcolor{preprocessor}{\#include <stddef.h>}}
  11. \DoxyCodeLine{8 \textcolor{preprocessor}{\#include <stdint.h>}}
  12. \DoxyCodeLine{9 }
  13. \DoxyCodeLine{10 \textcolor{preprocessor}{\#ifndef HASHTABLE\_SIZE\_BYTES}}
  14. \DoxyCodeLine{11 \textcolor{preprocessor}{\#define HASHTABLE\_SIZE\_BYTES (1024*1024)}}
  15. \DoxyCodeLine{12 \textcolor{preprocessor}{\#endif}}
  16. \DoxyCodeLine{13 }
  17. \DoxyCodeLine{14 \textcolor{preprocessor}{\#ifdef TOOLBOX\_TYPEDEF}}
  18. \DoxyCodeLine{15 \textcolor{keyword}{typedef} \textcolor{keyword}{struct }\mbox{\hyperlink{structhashtable}{hashtable}} hashtable\_st;}
  19. \DoxyCodeLine{16 \textcolor{preprocessor}{\#endif}}
  20. \DoxyCodeLine{17 }
  21. \DoxyCodeLine{18 \textcolor{keyword}{struct }\mbox{\hyperlink{structhashtable}{hashtable}};}
  22. \DoxyCodeLine{19 }
  23. \DoxyCodeLine{20 \_\_attribute\_\_((\_\_pure\_\_))}
  24. \DoxyCodeLine{21 \textcolor{keyword}{struct }\mbox{\hyperlink{structhashtable}{hashtable}} *}
  25. \DoxyCodeLine{22 hashtable\_create(\textcolor{keywordtype}{void});}
  26. \DoxyCodeLine{23 }
  27. \DoxyCodeLine{24 RET\_TYPE}
  28. \DoxyCodeLine{25 hashtable\_destroy(\textcolor{keyword}{struct} \mbox{\hyperlink{structhashtable}{hashtable}} **self);}
  29. \DoxyCodeLine{26 }
  30. \DoxyCodeLine{27 \_\_attribute\_\_((\_\_pure\_\_))}
  31. \DoxyCodeLine{28 \textcolor{keywordtype}{bool}}
  32. \DoxyCodeLine{29 hashtable\_contain\_item(\textcolor{keyword}{const} \textcolor{keyword}{struct} \mbox{\hyperlink{structhashtable}{hashtable}} *self}
  33. \DoxyCodeLine{30 , \textcolor{keyword}{const} \textcolor{keywordtype}{void}* item, \textcolor{keyword}{const} \textcolor{keywordtype}{size\_t} item\_size);}
  34. \DoxyCodeLine{31 }
  35. \DoxyCodeLine{32 \_\_attribute\_\_((\_\_pure\_\_))}
  36. \DoxyCodeLine{33 \textcolor{keywordtype}{bool}}
  37. \DoxyCodeLine{34 hashtable\_contain\_key(\textcolor{keyword}{const} \textcolor{keyword}{struct} \mbox{\hyperlink{structhashtable}{hashtable}} *self}
  38. \DoxyCodeLine{35 , \textcolor{keyword}{const} \textcolor{keywordtype}{char} *key);}
  39. \DoxyCodeLine{36 }
  40. \DoxyCodeLine{37 \_\_attribute\_\_((\_\_pure\_\_))}
  41. \DoxyCodeLine{38 \textcolor{keywordtype}{bool}}
  42. \DoxyCodeLine{39 hashtable\_contain\_key\_hash(\textcolor{keyword}{const} \textcolor{keyword}{struct} \mbox{\hyperlink{structhashtable}{hashtable}} *self}
  43. \DoxyCodeLine{40 , \textcolor{keyword}{const} \textcolor{keywordtype}{size\_t} key\_hash);}
  44. \DoxyCodeLine{41 }
  45. \DoxyCodeLine{42 \_\_attribute\_\_((\_\_pure\_\_))}
  46. \DoxyCodeLine{43 \textcolor{keyword}{const} \textcolor{keywordtype}{void} *}
  47. \DoxyCodeLine{44 hashtable\_get(\textcolor{keyword}{const} \textcolor{keyword}{struct} \mbox{\hyperlink{structhashtable}{hashtable}} *self}
  48. \DoxyCodeLine{45 , \textcolor{keyword}{const} \textcolor{keywordtype}{char} *key);}
  49. \DoxyCodeLine{46 }
  50. \DoxyCodeLine{47 \_\_attribute\_\_((\_\_pure\_\_))}
  51. \DoxyCodeLine{48 \textcolor{keyword}{const} \textcolor{keywordtype}{void} *}
  52. \DoxyCodeLine{49 hashtable\_get\_or\_default(\textcolor{keyword}{const} \textcolor{keyword}{struct} \mbox{\hyperlink{structhashtable}{hashtable}} *self}
  53. \DoxyCodeLine{50 , \textcolor{keyword}{const} \textcolor{keywordtype}{char} *key}
  54. \DoxyCodeLine{51 , \textcolor{keyword}{const} \textcolor{keywordtype}{void} *default\_item);}
  55. \DoxyCodeLine{52 }
  56. \DoxyCodeLine{53 \_\_attribute\_\_((\_\_pure\_\_))}
  57. \DoxyCodeLine{54 \textcolor{keywordtype}{bool}}
  58. \DoxyCodeLine{55 hashtable\_is\_empty(\textcolor{keyword}{const} \textcolor{keyword}{struct} \mbox{\hyperlink{structhashtable}{hashtable}} *self);}
  59. \DoxyCodeLine{56 }
  60. \DoxyCodeLine{57 RET\_TYPE}
  61. \DoxyCodeLine{58 hashtable\_put(\textcolor{keyword}{struct} \mbox{\hyperlink{structhashtable}{hashtable}} *self}
  62. \DoxyCodeLine{59 , \textcolor{keyword}{const} \textcolor{keywordtype}{char} *key}
  63. \DoxyCodeLine{60 , \textcolor{keyword}{const} \textcolor{keywordtype}{void} *item, \textcolor{keyword}{const} \textcolor{keywordtype}{size\_t} item\_size);}
  64. \DoxyCodeLine{61 }
  65. \DoxyCodeLine{62 \textcolor{keyword}{const} \textcolor{keywordtype}{void} *}
  66. \DoxyCodeLine{63 hashtable\_remove(\textcolor{keyword}{struct} \mbox{\hyperlink{structhashtable}{hashtable}} *self, \textcolor{keyword}{const} \textcolor{keywordtype}{char} *key);}
  67. \DoxyCodeLine{64 }
  68. \DoxyCodeLine{65 \textcolor{keywordtype}{bool}}
  69. \DoxyCodeLine{66 hashtable\_remove\_if\_equal(\textcolor{keyword}{struct} \mbox{\hyperlink{structhashtable}{hashtable}} *self}
  70. \DoxyCodeLine{67 , \textcolor{keyword}{const} \textcolor{keywordtype}{char} *key}
  71. \DoxyCodeLine{68 , \textcolor{keyword}{const} \textcolor{keywordtype}{void} *item, \textcolor{keyword}{const} \textcolor{keywordtype}{size\_t} item\_size);}
  72. \DoxyCodeLine{69 }
  73. \DoxyCodeLine{70 \textcolor{keyword}{const} \textcolor{keywordtype}{void} *}
  74. \DoxyCodeLine{71 hashtable\_replace(\textcolor{keyword}{struct} \mbox{\hyperlink{structhashtable}{hashtable}} *self}
  75. \DoxyCodeLine{72 , \textcolor{keyword}{const} \textcolor{keywordtype}{char} *key}
  76. \DoxyCodeLine{73 , \textcolor{keyword}{const} \textcolor{keywordtype}{void} *item, \textcolor{keyword}{const} \textcolor{keywordtype}{size\_t} item\_size);}
  77. \DoxyCodeLine{74 }
  78. \DoxyCodeLine{75 \textcolor{keywordtype}{bool}}
  79. \DoxyCodeLine{76 hashtable\_replace\_if\_equal(\textcolor{keyword}{struct} \mbox{\hyperlink{structhashtable}{hashtable}} *self}
  80. \DoxyCodeLine{77 , \textcolor{keyword}{const} \textcolor{keywordtype}{char} *key}
  81. \DoxyCodeLine{78 , \textcolor{keyword}{const} \textcolor{keywordtype}{void} *restrict old\_item}
  82. \DoxyCodeLine{79 , \textcolor{keyword}{const} \textcolor{keywordtype}{size\_t} item\_old\_size}
  83. \DoxyCodeLine{80 , \textcolor{keyword}{const} \textcolor{keywordtype}{void} *restrict new\_item}
  84. \DoxyCodeLine{81 , \textcolor{keyword}{const} \textcolor{keywordtype}{size\_t} item\_new\_size);}
  85. \DoxyCodeLine{82 }
  86. \DoxyCodeLine{83 \textcolor{keywordtype}{size\_t}}
  87. \DoxyCodeLine{84 hashtable\_used\_size(\textcolor{keyword}{const} \textcolor{keyword}{struct} \mbox{\hyperlink{structhashtable}{hashtable}} *self);}
  88. \DoxyCodeLine{85 }
  89. \DoxyCodeLine{86 RET\_TYPE}
  90. \DoxyCodeLine{87 hashtable\_for\_each(\textcolor{keyword}{struct} \mbox{\hyperlink{structhashtable}{hashtable}} *self}
  91. \DoxyCodeLine{88 , \textcolor{keywordtype}{void} (*for\_each)(\textcolor{keywordtype}{void} *item, \textcolor{keywordtype}{size\_t} *item\_size));}
  92. \DoxyCodeLine{89 }
  93. \DoxyCodeLine{90 \textcolor{preprocessor}{\#endif}}
  94. \end{DoxyCode}