dynar.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. #ifndef ERUTA_DYNAR_H
  2. #define ERUTA_DYNAR_H
  3. #include <stdlib.h> // need size_t
  4. // can use with every, so include the header
  5. #include "every.h"
  6. #include "mem.h"
  7. #ifndef FALSE
  8. #define FALSE 0
  9. #endif
  10. #ifndef TRUE
  11. #define TRUE 1
  12. #endif
  13. typedef struct Dynar_ Dynar;
  14. typedef struct Lilis_ Lilis;
  15. typedef int DynarCompare(const void * one, const void * two);
  16. int dynar_size (Dynar * self );
  17. int dynar_amount (Dynar * self );
  18. int dynar_elementsize (Dynar * self );
  19. Dynar * dynar_done (Dynar * self );
  20. Dynar * dynar_destroy (Dynar * self , MemDestructor * destroy );
  21. Dynar * dynar_free (Dynar * self );
  22. Dynar * dynar_free_destroy (Dynar * self , MemDestructor * destroy );
  23. Dynar * dynar_alloc(void);
  24. Dynar * dynar_initempty (Dynar * self , int elsz );
  25. Dynar * dynar_newempty (int elsz );
  26. Dynar * dynar_size_ (Dynar * self , int newsize );
  27. Dynar * dynar_init (Dynar * self , int amount , int elsz );
  28. Dynar * dynar_initptr (Dynar * self , int amount );
  29. Dynar * dynar_new (int amount , int elsz );
  30. Dynar * dynar_newptr (int amount );
  31. Dynar * dynar_grow (Dynar * self , int amount );
  32. int dynar_sizeindex_ok (Dynar * self , int index );
  33. int dynar_index_ok (Dynar * self , int index );
  34. void * dynar_getraw_unsafe (Dynar * self , int index );
  35. void * dynar_getcopy_unsafe (Dynar * self , int index , void * out );
  36. Dynar * dynar_putraw_unsafe (Dynar * self , int index , void * ptr );
  37. void * dynar_getraw (Dynar * self , int index );
  38. void * dynar_getcopy (Dynar * self , int index , void * ptr );
  39. Dynar * dynar_putraw (Dynar * self , int index , void * ptr );
  40. void * dynar_putptr (Dynar * self , int index , void * ptr );
  41. void * dynar_getptr (Dynar * self , int index );
  42. void * dynar_putdata (Dynar * self , int index , void * ptr );
  43. void * dynar_getdata (Dynar * self , int index );
  44. Dynar * dynar_putnullall(Dynar * self);
  45. Dynar * dynar_qsort(Dynar * self , DynarCompare * compare);
  46. void * dynar_lsearch(Dynar * self, const void * key, DynarCompare * compare);
  47. void * dynar_bsearch(Dynar * self, const void * key, DynarCompare * compare);
  48. Every * dynar_everynow_data (Every * every );
  49. Every * dynar_everynow_ptr (Every * every );
  50. Every * dynar_everyinit_data (Every * every );
  51. Every * dynar_everynext_data (Every * every );
  52. void * dynar_everyput_data (Every * every , void * data );
  53. void * dynar_everydone (Every * every );
  54. Every * dynar_everyinit_ptr (Every * every );
  55. Every * dynar_everynext_ptr (Every * every );
  56. void * dynar_everyput_ptr (Every * every , void * data );
  57. Every * dynar_every_data (Dynar * dynar );
  58. Every * dynar_every_ptr (Dynar * dynar );
  59. void * dynar_each_ptr (Dynar * self , EachDo * eachdo , void * extra );
  60. void * dynar_each_data(Dynar * self, EachDo * eachdo, void * extra);
  61. void * dynar_walkptr(Dynar * self, Walker * walker, void * extra);
  62. void * dynar_walkptrbetween(Dynar * self, int low, int high,
  63. Walker * walker, void * extra);
  64. void * dynar_walkdata(Dynar * self, Walker * walker, void * extra);
  65. void * dynar_walkmapptrbetween(Dynar * self, int low, int high,
  66. Walker * walker, void * extra);
  67. void * dynar_walkmapptr(Dynar * self, Walker * walker, void * extra);
  68. Dynar * dynar_resize(Dynar * self, int newsize, MemDestructor * destroy);
  69. Dynar * dynar_new_long();
  70. Dynar * dynar_put_long(Dynar * self, int index, long value);
  71. Dynar * dynar_get_long(Dynar * self, int index, long * value);
  72. Dynar * dynar_append_long(Dynar * self, long value);
  73. Dynar * dynar_destroy_structs(Dynar * self, MemDestructor * destroy);
  74. Dynar * dynar_destroy_structs_and_free(Dynar * self, MemDestructor * destroy);
  75. Lilis * lilis_freetail (Lilis * self );
  76. Lilis * lilis_done (Lilis * self );
  77. Lilis * lilis_free (Lilis * self );
  78. Lilis * lilis_alloc (void);
  79. Lilis * lilis_init (Lilis * self , Lilis * next , Lilis * prev , void * data );
  80. Lilis * lilis_initempty (Lilis * self );
  81. Lilis * lilis_new (Lilis * next , Lilis * prev , void * data );
  82. Lilis * lilis_newempty(void);
  83. Lilis * lilis_add (Lilis * self , Lilis * other );
  84. Lilis * lilis_addnew (Lilis * self , void * data );
  85. Lilis * lilis_removenext (Lilis * self );
  86. Lilis * lilis_remove (Lilis * self );
  87. Lilis * lilis_erase (Lilis * self );
  88. Lilis * lilis_erasenext (Lilis * self );
  89. Lilis * lilis_next (Lilis * self );
  90. Lilis * lilis_previous (Lilis * self );
  91. void * lilis_data (Lilis * self );
  92. #endif